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);
        }
Exemple #2
0
 static void Main(string[] args)
 {
     Frap myFrap = new CreamFrap();
     Console.WriteLine("frap1:  " + myFrap.GetDescription());
     myFrap = new CreamDecorator(myFrap);
     Console.WriteLine("frap2:  " + myFrap.GetDescription());
     Console.ReadLine();
 }
Exemple #3
0
        // Simulating a coffee shop where you could combine different ingredients at runtime

        static void Main(string[] args)
        {
            var coffee = new DecafCoffee();

            Console.WriteLine(coffee.Cost());
            Console.WriteLine(coffee.GetDescription());

            ICoffee decoratedCoffee = new MilkDecorator(coffee);

            Console.WriteLine(decoratedCoffee.Cost());
            Console.WriteLine(decoratedCoffee.GetDescription());

            decoratedCoffee = new CreamDecorator(decoratedCoffee);

            Console.WriteLine(decoratedCoffee.Cost());
            Console.WriteLine(decoratedCoffee.GetDescription());
        }
Exemple #4
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);
        }