Beispiel #1
0
        static void Main(string[] args)
        {
            //ItalianPizza
            Pizza pizzaIt1 = new ItalianPizza();

            Console.WriteLine("Название: {0}", pizzaIt1.Name);
            Console.WriteLine("Цена: {0}", pizzaIt1.GetCost());

            pizzaIt1 = new PlusTomatoPizza(pizzaIt1); // итальянская пицца с томатами
            Console.WriteLine("Название: {0}", pizzaIt1.Name);
            Console.WriteLine("Цена: {0}", pizzaIt1.GetCost());

            Pizza pizzaIt2 = new ItalianPizza();

            pizzaIt2 = new PlusCheesePizza(pizzaIt2);// итальянская пиццы с сыром
            Console.WriteLine("Название: {0}", pizzaIt2.Name);
            Console.WriteLine("Цена: {0}", pizzaIt2.GetCost());

            Console.WriteLine();

            //BulgerianPizza
            Pizza pizzaBul = new BulgerianPizza();

            Console.WriteLine("Название: {0}", pizzaBul.Name);
            Console.WriteLine("Цена: {0}", pizzaBul.GetCost());

            pizzaBul = new PlusTomatoPizza(pizzaBul);
            pizzaBul = new PlusCheesePizza(pizzaBul);// болгарская пиццы с томатами и сыром
            Console.WriteLine("Название: {0}", pizzaBul.Name);
            Console.WriteLine("Цена: {0}", pizzaBul.GetCost());

            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Pizza pizza1 = new ItalianPizza();

            Console.WriteLine($"Name '{pizza1.Name}'");
            Console.WriteLine($"Cost {pizza1.GetCost()}");
            pizza1 = new TomatoPizza(pizza1);
            Console.WriteLine($"Name '{pizza1.Name}'");
            Console.WriteLine($"Cost {pizza1.GetCost()}");


            Pizza pizza2 = new ItalianPizza();

            pizza2 = new CheesePizza(pizza2);
            Console.WriteLine($"Name '{pizza2.Name}'");
            Console.WriteLine($"Cost {pizza2.GetCost()}");


            Pizza pizza3 = new BulgerianPizza();

            pizza3 = new CheesePizza(pizza3);
            pizza3 = new TomatoPizza(pizza3);
            Console.WriteLine($"Name '{pizza3.Name}'");
            Console.WriteLine($"Cost {pizza3.GetCost()}");
        }