Exemple #1
0
        static void PrintAllPricesForBeverage(Beverage beverage)
        {
            var withMocha = new Mocha(beverage);

            var withWhip         = new Whip(beverage);
            var withMochaAndWhip = new Whip(withMocha);

            var withSoy                = new Soy(beverage);
            var withSoyAndWhip         = new Soy(withWhip);
            var withSoyAndMocha        = new Soy(withMocha);
            var withMochaAndWhipAndSoy = new Soy(withMochaAndWhip);

            Console.WriteLine($"-> {withMocha.GetDescription()}: {withMocha.Cost()}");
            Console.WriteLine($"-> {withWhip.GetDescription()}: {withWhip.Cost()}");
            Console.WriteLine($"-> {withMochaAndWhip.GetDescription()}: {withMochaAndWhip.Cost()}");
            Console.WriteLine($"-> {withSoy.GetDescription()}: {withSoy.Cost()}");
            Console.WriteLine($"-> {withSoyAndWhip.GetDescription()}: {withSoyAndWhip.Cost()}");
            Console.WriteLine($"-> {withSoyAndMocha.GetDescription()}: {withSoyAndMocha.Cost()}");
            Console.WriteLine($"-> {withMochaAndWhipAndSoy.GetDescription()}: {withMochaAndWhipAndSoy.Cost()}");
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            beverage = new Mocha(beverage);
            Console.WriteLine(beverage.GetDescription() + ", $" + beverage.GetCost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2.GetDescription() + ", $" + beverage2.GetCost());

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine(beverage3.GetDescription() + ", $" + beverage3.GetCost());

            Console.ReadLine();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost());

            beverage = new Mocha(beverage);
            Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost());

            beverage = new Mocha(beverage);
            Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost());

            beverage = new Whip(beverage);
            Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost());

            beverage.size = Size.Larger;
            Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost());

            beverage.size = Size.Middle;
            Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost());

            beverage.size = Size.Small;
            Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost());
        }