Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Beverage beverage1 = new HouseBlend();

            beverage1      = new Milk(beverage1);
            beverage1      = new Soy(beverage1);
            beverage1      = new Soy(beverage1);
            beverage1.Size = CupSize.Small;
            Console.WriteLine(string.Format("{0}: $ {1}", beverage1.GetDescription(), beverage1.Cost()));
            beverage1.Size = CupSize.Medium;
            Console.WriteLine(string.Format("{0}: $ {1}", beverage1.GetDescription(), beverage1.Cost()));
            beverage1.Size = CupSize.Large;
            Console.WriteLine(string.Format("{0}: $ {1}", beverage1.GetDescription(), beverage1.Cost()));
            beverage1 = new PrettyDescriptionDecorator(beverage1);
            Console.WriteLine(string.Format("{0}: $ {1}", beverage1.GetDescription(), beverage1.Cost()));
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Beverage beverage = new HouseBlend();

            beverage = new Milk(beverage);
            beverage = new Whip(beverage);
            beverage = new Whip(beverage);
            beverage = new Whip(beverage);
            beverage = new Whip(beverage);
            beverage = new Mocha(beverage);
            beverage = new Soy(beverage);
            Console.WriteLine($"{beverage.GetDescription()} {beverage.Cost()}");
        }
Ejemplo n.º 3
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()}");
        }