Beispiel #1
0
        static void Main(string[] args)
        {
            Beverage beverage1 = new DarkRoast();

            beverage1 = new Mocha(beverage1);
            beverage1 = new Whip(beverage1);

            Beverage beverage2 = new Decaf();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);

            Console.WriteLine(beverage1.getDescription());
            Console.WriteLine(beverage2.getDescription());
        }
        private static void DoWork()
        {
            Beverage espresso = new Espresso
            {
                Size = Beverage.SizeType.Tall
            };

            Console.WriteLine($"{espresso.GetDescription()} ${espresso.Cost()}");

            Beverage darkRoast = new DarkRoast
            {
                Size = Beverage.SizeType.Venti
            };

            darkRoast = new Mocha(darkRoast);
            darkRoast = new Mocha(darkRoast);
            darkRoast = new Whip(darkRoast);
            Console.WriteLine($"{darkRoast.GetDescription()} ${darkRoast.Cost()}");

            Beverage houseBlend = new HouseBlend
            {
                Size = Beverage.SizeType.Grande
            };

            houseBlend = new Soy(houseBlend);
            houseBlend = new Mocha(houseBlend);
            houseBlend = new Whip(houseBlend);
            Console.WriteLine($"{houseBlend.GetDescription()} ${houseBlend.Cost()}");

            Beverage decaf = new Decaf
            {
                Size = Beverage.SizeType.Venti
            };

            decaf = new SteamedMilk(decaf);
            decaf = new Mocha(decaf);
            Console.WriteLine($"{decaf.GetDescription()} ${decaf.Cost()}");
        }