Пример #1
0
        static void Main(string[] args)
        {
            IPizza   pizza = new Pizza();
            ITopping mozza = new Mozzarella();

            mozza.Component = pizza;
            ITopping pepe = new Peperoni()
            {
                Component = mozza
            };
            ITopping mozza2 = new Mozzarella();

            mozza2.Component = pepe;
            Console.WriteLine("cu de toate costa " + mozza2.GetCost());
            Console.ReadLine();
        }
Пример #2
0
        public static void Run()
        {
            IPizza p = new Pizza();

            //AbstractTopping topping1 = new Mozzarella2();
            //topping1.Component = p;

            //AbstractTopping topping2 = new Salami();
            //topping2.Component = topping1;
            ITopping topping1 = new Mozzarella();

            topping1.Component = p;
            ITopping topping2 = new Peperoni();

            topping2.Component = topping1;
            ITopping topping3 = new Shrooms();

            topping3.Component = topping2;
            Mozzarella extraBranza = new Mozzarella();

            extraBranza.Component = topping3;
            Console.WriteLine("Your pizza costs: " + extraBranza.GetCost());
        }