Beispiel #1
0
        private static void Main()
        {
            var cakeBase = new CakeBase();
            Console.WriteLine(cakeBase);

            var creamCake = new CreamDecorator(cakeBase);
            Console.WriteLine(creamCake);

            var cherryCake = new CherryDecorator(creamCake);
            Console.WriteLine(cherryCake);

            var scentedCake = new ArtificialScentDecorator(cherryCake);
            Console.WriteLine(scentedCake);

            var nameCardOnCake = new NameCardDecorator(scentedCake);
            Console.WriteLine(nameCardOnCake);

            var pastry = new PastryBase();
            Console.WriteLine(pastry);

            var creamPastry = new CreamDecorator(pastry);
            var cherryPastry = new CherryDecorator(creamPastry);
            var scentedPastry = new ArtificialScentDecorator(cherryPastry);
            Console.WriteLine(scentedPastry);
        }
Beispiel #2
0
        public static void Main()
        {
            // Let us create a Simple Cake Base first
            CakeBase cakeBase = new CakeBase();

            PrintProductDetails(cakeBase);

            // Lets add cream to the cake
            CreamDecorator creamCake = new CreamDecorator(cakeBase);

            PrintProductDetails(creamCake);

            // Let now add a Cherry on it
            CherryDecorator cherryCake = new CherryDecorator(creamCake);

            PrintProductDetails(cherryCake);

            // Lets now add Scent to it
            ArtificialScentDecorator scentedCake = new ArtificialScentDecorator(cherryCake);

            PrintProductDetails(scentedCake);

            // Finally add a Name card on the cake
            NameCardDecorator nameCardOnCake = new NameCardDecorator(scentedCake);

            PrintProductDetails(nameCardOnCake);

            // Lets now create a simple Pastry
            PastryBase pastry = new PastryBase();

            PrintProductDetails(pastry);

            // Lets just add cream and cherry only on the pastry
            CreamDecorator  creamPastry  = new CreamDecorator(pastry);
            CherryDecorator cherryPastry = new CherryDecorator(creamPastry);

            PrintProductDetails(cherryPastry);
        }