Пример #1
0
        static void Main(string[] args)
        {
            BeverageItem drink = new Latte();

            IBeverageExtension sugar    = new SugarExtension();
            IBeverageExtension toppings = new ToppingsExtension();

            drink.RegisterExtension(sugar);
            drink.RegisterExtension(toppings);

            if (drink.HasExtension(sugar))
            {
                ((SugarExtension)drink.GetExtension("SugarExtension")).AddSugar(3);
            }

            if (drink.HasExtension(toppings))
            {
                ((ToppingsExtension)drink.GetExtension("ToppingsExtension")).AddTopping(new ToppingHelper.Topping[]
                {
                    ToppingHelper.Topping.Caramel,
                    ToppingHelper.Topping.Chocolate
                });
            }

            drink.GetInfo();

            //drink.UnregisterExtension(sugar);

            //drink.GetInfo();

            //Console.WriteLine($"Turi sugar?: {drink.HasExtension(sugar)}");

            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Starbuck  coffee = new Latte();
            SweetCake cake1  = new SweetCake();

            cake1.SetFood(coffee);
            PlainCake cake2 = new PlainCake();

            cake2.SetFood(cake1);
            cake2.Show();

            Console.Read();
        }
Пример #3
0
        static void Main(string[] args)
        {
            //Order a Latte with Cream
            Coffee latteWithCream = new Latte();
            latteWithCream = new WhipCream(latteWithCream);
            Console.WriteLine(latteWithCream.GetDescription() + " at $" + latteWithCream.GetCost());

            //Order an Expresso with Caramel and Cream
            Coffee expressoWithCaramelAndCream = new Expresso();
            expressoWithCaramelAndCream = new WhipCream(expressoWithCaramelAndCream);
            expressoWithCaramelAndCream = new Caramel(expressoWithCaramelAndCream);
            Console.WriteLine(expressoWithCaramelAndCream.GetDescription() + " at $" + expressoWithCaramelAndCream.GetCost());
        }
Пример #4
0
        static void Main(string[] args)
        {
            Beverage coffee = new Latte();

            Console.WriteLine("Current coffee is: {0}, cost is {1}.", coffee.GetDescription(), coffee.Cost());

            Beverage latteWithMilk         = new Milk(coffee);
            Beverage latteWithMilkAndMocha = new Mocha(latteWithMilk);

            Console.WriteLine("Current coffee is: {0}, cost is {1}.", latteWithMilkAndMocha.GetDescription(), latteWithMilkAndMocha.Cost());

            Beverage latteWithMilkAndDoubleMocha = new Mocha(latteWithMilkAndMocha);

            Console.WriteLine("Current coffee is: {0}, cost is {1}.", latteWithMilkAndDoubleMocha.GetDescription(), latteWithMilkAndDoubleMocha.Cost());
        }
Пример #5
0
        static void Main(string[] args)
        {
            //Order a Latte with Cream
            Coffee latteWithCream = new Latte();

            latteWithCream = new WhipCream(latteWithCream);
            Console.WriteLine(latteWithCream.GetDescription() + " at $" + latteWithCream.GetCost());

            //Order an Expresso with Caramel and Cream
            Coffee expressoWithCaramelAndCream = new Expresso();

            expressoWithCaramelAndCream = new WhipCream(expressoWithCaramelAndCream);
            expressoWithCaramelAndCream = new Caramel(expressoWithCaramelAndCream);
            Console.WriteLine(expressoWithCaramelAndCream.GetDescription() + " at $" + expressoWithCaramelAndCream.GetCost());
        }
Пример #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("We have these fabulous drinkings.");

            Beverage espresso    = new Espresso();
            Beverage latte       = new Latte();
            Beverage orangejuice = new OrangeJuice();

            Console.WriteLine($"Espresso : {espresso.Description} \\.{espresso.Cost()}");
            Console.WriteLine($"Latte : {espresso.Description} \\.{latte.Cost()}");
            Console.WriteLine($"OrangeJuice : {espresso.Description} \\.{orangejuice.Cost()}");

            Beverage mochaLatte = new Mocha(new Latte());

            Console.WriteLine($"Mocha Latte : {mochaLatte.Description} \\.{mochaLatte.Cost()}");

            Console.ReadLine();
        }