コード例 #1
0
ファイル: Program.cs プロジェクト: dp140719/17.07.2019
        static void Main(string[] args)
        {
            IPizza pizza = new BasePizza();

            IPizza pizzaWithTomato             = new TomatoTopping(pizza);
            IPizza pizzaWithTomatoAndPineapple = new PineaappleTopping(pizzaWithTomato);

            Console.WriteLine(pizzaWithTomatoAndPineapple.GetDetails());
            Console.WriteLine(pizzaWithTomatoAndPineapple.GetPrice());

            IPizza myfavoritePizza = new TomatoTopping(new CheeseTopping(new BasePizza()));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: dotnet111119/25.06.2020
        static void Main(string[] args)
        {
            IPizza basePizza = new BasePizza();

            // redundent
            IPizza basePizzaWithCheese = new CheeseToppings(basePizza);

            // important -- only this i need reference for
            IPizza pizzaWithCheeseAndTomato = new TomatoTopping(basePizzaWithCheese);

            Console.WriteLine(pizzaWithCheeseAndTomato.GetDetails());
            Console.WriteLine(pizzaWithCheeseAndTomato.GetPrice());

            IPizza pizzaWithPineappleAndTomatoAndBulgarit =
                new BulgaritTopping(new TomatoTopping(new PineappleDecorator(new BasePizza())));

            Console.WriteLine(pizzaWithPineappleAndTomatoAndBulgarit.GetDetails());
            Console.WriteLine(pizzaWithPineappleAndTomatoAndBulgarit.GetPrice());
        }