Ejemplo n.º 1
0
        public void GetIngredients(Store store)
        {
            Console.WriteLine("How many cups would you like?");
            string userInputCup = Console.ReadLine();
            int    cupsPurchased;

            cupsPurchased = Int32.Parse(userInputCup);
            inventory.BuyCups(store.SellCups(cupsPurchased, bank));

            Console.WriteLine("How many lemons?\n");
            string userInputLemon = Console.ReadLine();
            int    lemonsPurchased;

            lemonsPurchased = Int32.Parse(userInputLemon);
            inventory.BuyLemons(store.SellLemons(lemonsPurchased, bank));

            Console.WriteLine("How many cups of sugar?\n");
            string userInputSugar = Console.ReadLine();
            int    sugarPurchased;

            sugarPurchased = Int32.Parse(userInputSugar);
            inventory.BuySugar(store.SellSugar(sugarPurchased, bank));

            Console.WriteLine("And, finally, how much ice?\n");
            string userInputIce = Console.ReadLine();
            int    icePurchased;

            icePurchased = Int32.Parse(userInputIce);
            inventory.BuyIce(store.SellIce(icePurchased, bank));

            Console.WriteLine($"So, for today you have {cupsPurchased} cups, {lemonsPurchased} lemons, {sugarPurchased} cups of sugar and {icePurchased} ice cubes. Now, let's make your lemonade recipe!\n");
        }
Ejemplo n.º 2
0
        public void BuyIngredients()
        {
            Console.WriteLine($"You have ${Inventory.Balance}");
            Console.WriteLine("Choose an item to buy from the store.");
            Console.WriteLine($"1. Store bought lemonade. Price: ${BasicRecipe.GetCost()}");
            Console.WriteLine($"2. Lemon. Price: ${Store.LemonPrice}");
            Console.WriteLine($"3. Sugar Packets. Price: ${Store.SugarPrice}");
            Console.WriteLine($"4. Ice Cubes. Price: ${Store.IcePrice}");
            Console.WriteLine($"5. Done shopping.");

            while (true)
            {
                Console.WriteLine("What would you like to buy? ");
                int userInput = Validation.ReadUserInput(5);
                switch (userInput)
                {
                case 1:
                {
                    BuyItem((count) => { Inventory.BuyBasicRecipe(count); dayLoss -= count * BasicRecipe.GetCost(); }, BasicRecipe.GetCost());
                    break;
                }

                case 2:
                {
                    BuyItem((count) => { Inventory.BuyLemon(count); dayLoss -= count * Store.LemonPrice; }, Store.LemonPrice);
                    break;
                }

                case 3:
                {
                    BuyItem((count) => { Inventory.BuySugar(count); dayLoss -= count * Store.SugarPrice; }, Store.SugarPrice);
                    break;
                }

                case 4:
                {
                    BuyItem((count) => { Inventory.BuyIce(count); dayLoss -= count * Store.IcePrice; }, Store.IcePrice);
                    break;
                }

                case 5:
                {
                    return;
                }
                }
            }
        }