Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            CakeBase cakeBase = new CakeBase();

            PrintProductDetails(cakeBase);

            CreamDecorator creamCake = new CreamDecorator(cakeBase);

            PrintProductDetails(creamCake);

            CherryDecorator cherryCake = new CherryDecorator(creamCake);

            PrintProductDetails(cherryCake);

            ArtificialScentDecorator scentedCake = new ArtificialScentDecorator(cherryCake);

            PrintProductDetails(scentedCake);

            NameCardDecorator nameCardCake = new NameCardDecorator(scentedCake);

            PrintProductDetails(nameCardCake);

            PastryBase pastryBase = new PastryBase();

            PrintProductDetails(pastryBase);

            CreamDecorator  creamPastry  = new CreamDecorator(pastryBase);
            CherryDecorator cherryPastry = new CherryDecorator(creamPastry);

            PrintProductDetails(cherryPastry);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static void Execute()
        {
            // Let us create a Simple Cake Base first
            CakeBase cBase = new CakeBase();

            PrintProductDetails(cBase);

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

            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);
        }