public void BuyIce(Inventory inventory) { Console.WriteLine("Would you like to buy ice?"); string userInput = Console.ReadLine().ToLower(); double price = .20; switch (userInput) { case "yes": Console.WriteLine($"Ice costs ${price}. How much ice would you like to buy?"); double buyIce = Convert.ToDouble(Console.ReadLine()); double moneyToRemove = buyIce * price; Console.WriteLine($"You have bought {buyIce} ice for ${moneyToRemove}"); Console.ReadLine(); inventory.RemoveMoney(moneyToRemove, inventory); inventory.ice = Convert.ToInt32(inventory.ice + buyIce); inventory.CalculateLoss(moneyToRemove); break; case "no": break; default: Console.WriteLine("Wrong input, please type 'yes' or 'no'."); BuyIce(inventory); break; } }
public void BuyLemons(Inventory inventory) { Console.WriteLine("Would you like to buy lemons?"); string userInput = Console.ReadLine().ToLower(); double price = .25; switch (userInput) { case "yes": Console.WriteLine($"Lemons cost: {price} How many lemons would you like to buy?"); double buyLemons = Convert.ToDouble(Console.ReadLine()); double moneyToRemove = buyLemons * price; Console.WriteLine($"You have bought {buyLemons} lemons for ${moneyToRemove}"); Console.ReadLine(); inventory.RemoveMoney(moneyToRemove, inventory); inventory.lemons = Convert.ToInt32(inventory.lemons + buyLemons); inventory.CalculateLoss(moneyToRemove); break; case "no": break; default: Console.WriteLine("Wrong input, please type 'yes' or 'no'. "); BuyLemons(inventory); break; } }
public void BuySugar(Inventory inventory) { Console.WriteLine("Would you like to buy sugar?"); string userInput = Console.ReadLine().ToLower(); double price = .21; switch (userInput) { case "yes": Console.WriteLine($"Sugar costs: ${price}. How much sugar do you wish to buy?"); double buySugar = Convert.ToDouble(Console.ReadLine()); double moneyToRemove = buySugar * price; Console.WriteLine($"You have bought: {buySugar} sugar for ${moneyToRemove}. "); Console.ReadLine(); inventory.RemoveMoney(moneyToRemove, inventory); inventory.sugar = Convert.ToInt32(inventory.sugar + buySugar); inventory.CalculateLoss(moneyToRemove); break; case "no": break; default: Console.WriteLine("Wrong user input, please type 'yes' or 'no'."); BuySugar(inventory); break; } }
public void GetProfit(Inventory inventory) { inventory.CalculateProfit(inventory.moneyToAdd); inventory.CalculateLoss(inventory.moneyToRemove); inventory.RunningProfit(inventory); }