Пример #1
0
        public static void Main(string[] args)
        {
            ICoffee coffee = new SimpleCoffee();

            Print(coffee);

            coffee = new WithMilkDecorator(coffee);
            Print(coffee);

            coffee = new WithSprinklesDecorator(coffee);
            Print(coffee);

            Console.ReadKey(true);
        }
Пример #2
0
        static void Main(string[] args)
        {
            ICoffee coffee = new SimpleCoffee();

            PrintInfo(coffee);

            coffee = new WithMilk(coffee);
            PrintInfo(coffee);

            coffee = new WithSprinkles(coffee);
            PrintInfo(coffee);

            Console.ReadLine();
        }
Пример #3
0
        static void Main(string[] args)
        {
            var myCoffee = new SimpleCoffee();

            Console.WriteLine("{0:c}", myCoffee.GetCost());      // $ 5.00
            Console.WriteLine("{0}", myCoffee.GetDescription()); // Simple Coffee

            var milkCoffee = new MilkCoffee(myCoffee);

            Console.WriteLine("{0:c}", milkCoffee.GetCost());      // $ 6.00
            Console.WriteLine("{0}", milkCoffee.GetDescription()); // Simple Coffee, milk

            var whipCoffee = new WhipCoffee(milkCoffee);

            Console.WriteLine("{0:c}", whipCoffee.GetCost());      // $ 7.00
            Console.WriteLine("{0}", whipCoffee.GetDescription()); // Simple Coffee, milk, whip

            var vanillaCoffee = new VanillaCoffee(whipCoffee);

            Console.WriteLine("{0:c}", vanillaCoffee.GetCost());      // $ 8.00
            Console.WriteLine("{0}", vanillaCoffee.GetDescription()); // Simple Coffee, milk, whip
            Console.ReadLine();
        }