static void Main(string[] args)
        {
            #region Sandwich

            SandwichBase mySandwich = new VeggieSandwich();

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

            mySandwich = new Cheese(mySandwich);
            Console.WriteLine(mySandwich.GetPrice());
            Console.WriteLine(mySandwich.GetDescription());

            mySandwich = new Olives(mySandwich);
            Console.WriteLine(mySandwich.GetPrice());
            Console.WriteLine(mySandwich.GetDescription());

            #endregion

            #region Pizza

            var pizza = new PizzaBase();

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

            Console.WriteLine($"Pizza Description: {pizza.Description}");

            #endregion
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Sandwich mySandwich = new VeggieSandwich();

            Console.WriteLine(mySandwich.GetPrize());
            Console.WriteLine(mySandwich.GetDescription());
            mySandwich = new Cheese(mySandwich);
            Console.WriteLine(mySandwich.GetPrize());
            Console.WriteLine(mySandwich.GetDescription());
            mySandwich = new Corn(mySandwich);
            Console.WriteLine(mySandwich.GetPrize());
            Console.WriteLine(mySandwich.GetDescription());
            mySandwich = new Olives(mySandwich);
            Console.WriteLine(mySandwich.GetPrize());
            Console.WriteLine(mySandwich.GetDescription());
        }