예제 #1
0
 public void TotalItemCost(string itemName, double costPerItem, double amountOfItem, Player player, Inventory inventory)
 {
     checkBalance = player.CheckBalance(costPerItem * amountOfItem);
     if (checkBalance == true)
     {
         double x;
         for (x = 0; x <= amountOfItem; x++)
         {
             AddToAnyInventory();
         }
         totlaItemCost      = (costPerItem * amountOfItem);
         player.playerMoney = player.GetPlayerMoney();
         player.playerMoney = player.playerMoney - totlaItemCost;
         Console.WriteLine("You bought {0} units of {1}", amountOfItem, itemName);
         Console.WriteLine("You now have ${0} left", player.playerMoney);
         Console.WriteLine("");
     }
     else if (checkBalance == false)
     {
         Console.WriteLine("You don't have enough money to purchase that. Enter a smaller amount.");
         selectItemAmount(itemName, costPerItem, player, inventory);
     }
     else
     {
         Console.WriteLine("ERROR");
     }
 }