예제 #1
0
        static void Main(string[] args)
        {
            IPizza pizza = new BasePizza();

            IPizza pizzaWithTomato             = new TomatoTopping(pizza);
            IPizza pizzaWithTomatoAndPineapple = new PineaappleTopping(pizzaWithTomato);

            Console.WriteLine(pizzaWithTomatoAndPineapple.GetDetails());
            Console.WriteLine(pizzaWithTomatoAndPineapple.GetPrice());

            IPizza myfavoritePizza = new TomatoTopping(new CheeseTopping(new BasePizza()));
        }
예제 #2
0
        static void Main(string[] args)
        {
            IPizza basePizza = new BasePizza();

            // redundent
            IPizza basePizzaWithCheese = new CheeseToppings(basePizza);

            // important -- only this i need reference for
            IPizza pizzaWithCheeseAndTomato = new TomatoTopping(basePizzaWithCheese);

            Console.WriteLine(pizzaWithCheeseAndTomato.GetDetails());
            Console.WriteLine(pizzaWithCheeseAndTomato.GetPrice());

            IPizza pizzaWithPineappleAndTomatoAndBulgarit =
                new BulgaritTopping(new TomatoTopping(new PineappleDecorator(new BasePizza())));

            Console.WriteLine(pizzaWithPineappleAndTomatoAndBulgarit.GetDetails());
            Console.WriteLine(pizzaWithPineappleAndTomatoAndBulgarit.GetPrice());
        }