Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Pizza basicPizza = new TomatoSauce(new Mozzarella(new PlainPizza()));

            Console.WriteLine("Ingredients: " + basicPizza.getDescription());

            Console.WriteLine("Cost: " + basicPizza.getCost());
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            // The PlainPizza object is sent to the Mozzarella constructor
            // and then to the TomatoSauce constructor
            // you can see the adding of salami in the seccond object and how the output changes.

            IPizza basicPizza = new TomatoSauce(new Mozzarella(new PlainPizza()));

            //Example of one more Decorator

            //IPizza basicPizza = new Salami(new TomatoSauce(new Mozzarella(new PlainPizza())));

            Console.WriteLine("Ingredients: " + basicPizza.GetDescription());
            Console.WriteLine("Price: " + basicPizza.GetCost());
            Console.ReadKey();
        }