Exemple #1
0
 public int BuyXUnits(IngredientsForPurchase ingredientChoice)
 {
     UI.ShowInformation($"How many would you like to buy?");
     ingredientAmount = Convert.ToInt32(Console.ReadLine());
     UI.ShowInformation($"{ingredientAmount} {ingredientChoice.name} purchased.");
     return(ingredientAmount);
 }
 public void IncreaseInventory(int amountPurchased, IngredientsForPurchase ingredient)
 {
     if (ingredient.name == "lemon")
     {
         lemons += amountPurchased;
     }
     else if (ingredient.name == "ice cubes")
     {
         ice += amountPurchased;
     }
     else if (ingredient.name == "sugar")
     {
         sugar += amountPurchased;
     }
 }
Exemple #3
0
        public static IngredientsForPurchase WhatToBuy(Player player)
        {
            UI.ShowInformation("What product would you like to buy? 'lemon' ('l'), 'ice' ('i'), or 'sugar' ('s'). You may also 'close' ('c') to close the shop.");
            string ingredientChoice = Console.ReadLine();

            switch (ingredientChoice)
            {
            case "close":
            case "c":
                UI.ShowInformation("Skipping the shop\n");
                UI.DisplayInventory(player);
                return(ingredient);

            case "lemon":
            case "l":
                UI.ShowInformation("purchasing lemons");
                UI.DisplayInventory(player);
                return(ingredient = new Lemon());

            case "ice":
            case "i":
                UI.ShowInformation("purchasing ice cubes");
                UI.DisplayInventory(player);
                return(ingredient = new IceCubes());

            case "sugar":
            case "s":
                UI.ShowInformation("purchasing sugar");
                UI.DisplayInventory(player);
                return(ingredient = new Sugar());

            default:
                UI.ShowInformation("please make a valid selection - 'lemon' ('l'), 'ice' ('i'), 'sugar' ('s'), or 'close' ('c').");
                UI.DisplayInventory(player);
                return(WhatToBuy(player));
            }
        }
Exemple #4
0
 public double CalculateTotalCost(IngredientsForPurchase ingredientChoice) // Player player
 {
     totalPurchasePrice = ingredientAmount * ingredientChoice.price;
     UI.ShowInformation($"The total cost of this purchase is ${totalPurchasePrice}.");
     return(totalPurchasePrice);
 }