예제 #1
0
        static void Main()
        {
            IPizza pizza = new Pizza("medium");

            Console.WriteLine(pizza.ShowIngredients());
            Console.WriteLine("Price: " + pizza.ShowPrice());

            IPizza pepperoniPizza = new PepperoniDecorator(pizza);

            Console.WriteLine(pepperoniPizza.ShowIngredients());
            Console.WriteLine("Price: " + pepperoniPizza.ShowPrice());

            IPizza sauceAndPepperoniPizza = new TomatoSauceDecorator(pepperoniPizza);

            Console.WriteLine(sauceAndPepperoniPizza.ShowIngredients());
            Console.WriteLine("Price: " + sauceAndPepperoniPizza.ShowPrice());

            IPizza saucePepperoniAndCheesePizza = new FourCheeseDecorator(sauceAndPepperoniPizza);

            Console.WriteLine(saucePepperoniAndCheesePizza.ShowIngredients());
            Console.WriteLine("Price: " + saucePepperoniAndCheesePizza.ShowPrice());
        }
예제 #2
0
        public static void Main()
        {
            PizzaComponent tunaPizza = new TunaPizza();

            Console.WriteLine(tunaPizza.GetDescription());
            Console.WriteLine("Cost: " + tunaPizza.Cost());

            Console.WriteLine();

            CheeseDecorator pizzaWithCheese = new CheeseDecorator(tunaPizza);

            Console.WriteLine(pizzaWithCheese.GetDescription());
            Console.WriteLine("Cost: " + pizzaWithCheese.Cost());

            pizzaWithCheese.MeltCheese();

            Console.WriteLine();

            PizzaComponent deliciousPizza = new PepperoniDecorator(new PineappleDecorator(pizzaWithCheese));

            Console.WriteLine(deliciousPizza.GetDescription());
            Console.WriteLine("Cost: " + deliciousPizza.Cost());
        }