Beispiel #1
0
        public BasicRecipe CreateProduct()
        {
            Console.WriteLine($"Inventory:");
            Console.WriteLine($"Store bought lemonade = {Inventory.BasicRecipe}");
            Console.WriteLine($"Lemons = {Inventory.Lemon}");
            Console.WriteLine($"Sugar Packets = {Inventory.Sugar}");
            Console.WriteLine($"Ice Cubes = {Inventory.Ice}");

            if (Inventory.BasicRecipe == 0 &&
                Inventory.Lemon == 0 &&
                Inventory.Sugar == 0 &&
                Inventory.Ice == 0 &&
                Inventory.Balance <= Store.IcePrice)
            {
                return(null);
            }


            while (true)
            {
                Console.WriteLine("What would you like to sell today?");
                Console.WriteLine("1. Store bought lemonade");
                Console.WriteLine("2. Homemade lemonade");

                switch (Validation.ReadUserInput(2))
                {
                case 1:
                {
                    Console.WriteLine("How many store bought lemonade do you want to sell?");
                    var amount = Validation.ReadDoubleLine();
                    if (Inventory.GetBasicRecipe(amount))
                    {
                        return(new BasicRecipe(amount));
                    }
                    else
                    {
                        Console.WriteLine("You don't have enough.");
                    }
                    break;
                }

                case 2:
                {
                    Console.WriteLine("How many lemons would you like to use?");
                    var lemonAmount = Validation.ReadDoubleLine();
                    if (!Inventory.CanGetLemon(lemonAmount))
                    {
                        Console.WriteLine("You don't have enough.");
                        break;
                    }
                    Console.WriteLine("How many sugar packets would you like to use?");
                    var sugarAmount = Validation.ReadDoubleLine();
                    if (!Inventory.CanGetSugar(sugarAmount))
                    {
                        Console.WriteLine("You don't have enough.");
                        break;
                    }
                    Console.WriteLine("How many ice cubes would you like to use?");
                    var iceAmount = Validation.ReadDoubleLine();
                    if (!Inventory.CanGetIce(iceAmount))
                    {
                        Console.WriteLine("You don't have enough.");
                        break;
                    }

                    Inventory.GetIce(iceAmount);
                    Inventory.GetSugar(sugarAmount);
                    Inventory.GetLemon(lemonAmount);

                    return(new CustomRecipe(lemonAmount, sugarAmount, iceAmount));
                }
                }
            }
        }