Example #1
0
        static void Main(string[] args)
        {
            IBeverage cappuccino         = new CappuccinoBeverage();
            IBeverage soyMochaCappuccino = new SoyBeverageDecorator((new MochaBeverageDecorator(cappuccino)));

            Console.WriteLine(soyMochaCappuccino.GetDescription());
            Console.WriteLine("Cost of the Soy Mocha Cappuccino is " + soyMochaCappuccino.GetCost());

            MenuCompositeComponent.TestCompositePattern();
            Console.ReadLine();
        }
Example #2
0
        public static void TestCompositePattern()
        {
            var menuComposite = new MenuCompositeComponent();

            menuComposite.AddComponent(new MenuItemComponent("Save"));
            menuComposite.AddComponent(new MenuItemComponent("Save As"));
            menuComposite.AddComponent(new MenuItemComponent("Delete"));

            IComponent component = menuComposite;

            component.SayMyName();
        }