Example #1
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            Console.WriteLine(beverage.getDescription() + " $" + beverage.cost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2.getDescription() + " $" + beverage2.cost());

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Mocha(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine(beverage3.getDescription() + " $" + beverage3.cost());
            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            //Order 1: houseblend with milk and 2xwhipped cream
            Beverage houseBlend = new HouseBlend();

            houseBlend = new MilkCondiment(houseBlend);
            houseBlend = new WhippedCreamCondiment(houseBlend);
            houseBlend = new WhippedCreamCondiment(houseBlend);
            var description = houseBlend.GetDescription();
            var price       = houseBlend.GetPrice();

            Console.WriteLine($"Ordered {description}. The price is: {price}");

            //Order 2: darkroast with soy milk and whipped cream
            Beverage darkRoast = new DarkRoast();

            darkRoast = new SoyCondiment(darkRoast);
            darkRoast = new WhippedCreamCondiment(darkRoast);
            darkRoast = new ChocolateCondiment(darkRoast);
            var darkRoastDescription = darkRoast.GetDescription();
            var darkRoastPrice       = darkRoast.GetPrice();

            Console.WriteLine($"darkRoastDescription {darkRoastDescription}. The price is: {darkRoastPrice}");
        }