Beispiel #1
0
        static void Main(string[] args)
        {
            IProduct pizza = new Pizza();

            pizza = new PepperoniDecorator(pizza);
            pizza = new PineappleDecorator(pizza);

            Console.WriteLine(pizza.GetDescription());
            Console.WriteLine(pizza.GetPrice());

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Set Large size (default), add Sauce, add Mozzarella cheese (default), add Olives, add Mushrooms, add Pepperoni, then build it.
            var builderPizza = new PizzaBuilder()
                               .AddSauce()
                               .AddCheese()
                               .AddOlives()
                               .AddMushrooms()
                               .AddPepperoni()
                               .Build();

            Logging.Log(builderPizza);

            Logging.LineSeparator();

            // Create a basic pizza.
            var pizza = new PizzaBase();

            Logging.Log(pizza.Description);

            // Decorate the base pizza by adding olives.
            var olives = new OlivesDecorator(pizza);

            Logging.Log(olives.Description);

            // Add mushrooms.
            var mushrooms = new MushroomsDecorator(olives);

            Logging.Log(mushrooms.Description);

            // Add pepperoni.
            var pepperoni = new PepperoniDecorator(mushrooms);

            Logging.Log(pepperoni.Description);

            // Add pineapple.
            var pineapple = new PineappleDecorator(pepperoni);

            Logging.Log(pineapple.Description);
        }