public void sellBagOfIceCubes(Player player) { int userInput; do { Console.WriteLine(""); Console.WriteLine($"How many bags of ice cubes would you like to buy? You currently have ${player.wallet.cash}.00 to spend"); // int userInput = int.Parse(Console.ReadLine()); } while (!int.TryParse(Console.ReadLine(), out userInput)); int totalIceCubesCost = priceBagOfIceCubes * userInput; if (player.wallet.cash >= priceBagOfIceCubes) { Console.WriteLine($"You are buying {userInput} bag(s) of ice cubes, for a total price of {totalIceCubesCost}"); player.wallet.cash -= totalIceCubesCost; Console.WriteLine($"You now have {player.wallet.cash} in your wallet"); for (int i = 0; i < userInput; i++) { IceCube ice = new IceCube(); player.inventory.iceCubes.Add(new IceCube()); } Console.WriteLine($"You've added {userInput} bags of ice to your inventory"); } else { Console.WriteLine(" You don't have enough money for that, please try a different amount."); sellBagOfIceCubes(player); } }
public void AddIceCubeInv(Player player, double iceCubeAmountPrompt) { for (int i = 0; i < iceCubeAmountPrompt; i++) { IceCube iceCube = new IceCube(); player.inventory.iceCubes.Add(iceCube); } }
public void AddIceCubesToInventory(int numberOfIceCubes) { for (int i = 0; i < numberOfIceCubes; i++) { IceCube iceCube = new IceCube(); iceCubes.Add(iceCube); } }