public IHotDrink CreateDrink()
        {
            IHotDrink Coffee = DrinkFactory.CreateHotDrink(Program.AvailableDrink.Coffee);

            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine("Do you want milk in your drink? ");
            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine("1.Yes\n2.No ");
            Console.WriteLine("----------------------------------------------------");

            Console.Write("please input your answer: ");
            string answer = Console.ReadLine().ToLower();

            bool confirmed = Coffee.ConfirmPayment(Coffee);

            if (confirmed)
            {
                if (answer.Equals("yes"))
                {
                    IHotDrink coffeeWithMilk = new MilkyDrinkDecorator(Coffee);
                    coffeeWithMilk.Prepare();
                }
                else
                {
                    Coffee.Prepare();
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Incorrect payment, try again.");
            }
            Console.Clear();
            return(Coffee);
        }
Пример #2
0
        public IHotDrink CreateDrink()
        {
            IHotDrink Latte     = DrinkFactory.CreateHotDrink(Program.AvailableDrink.Latte);
            bool      confirmed = Latte.ConfirmPayment(Latte);

            if (confirmed)
            {
                Latte.Prepare();
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Incorrect payment, try again.");
            }
            Console.Clear();
            return(Latte);
        }