예제 #1
0
        static void Main(string[] args)
        {
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);
            largePizza = new Ham(new Peppers(largePizza));

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());

            Console.ReadKey();
        }
예제 #2
0
        public static void FirstDemo()
        {
            Pizza small  = new SmallPizza();
            Pizza medium = new MediumPizza();
            Pizza large  = new LargePizza();

            var pizzas = new List <Pizza> {
                small, medium, large
            };


            Console.WriteLine($"Normal Pizza Prices");
            PrintPizzaPrices(pizzas);
            pizzas.Clear();

            Console.WriteLine($"Pizza Prices with Cheese");
            small  = new Cheese(small);
            medium = new Cheese(medium);
            large  = new Cheese(large);
            pizzas = new List <Pizza> {
                small, medium, large
            };
            PrintPizzaPrices(pizzas);
            pizzas.Clear();

            Console.WriteLine($"Pizza Prices with Cheese && Peperonni");

            small  = new Pepperenni(small);
            medium = new Pepperenni(medium);
            large  = new Pepperenni(large);
            pizzas = new List <Pizza> {
                small, medium, large
            };
            PrintPizzaPrices(pizzas);

            small  = new CreamySauce(small);
            medium = new CreamySauce(medium);
            large  = new CreamySauce(large);

            pizzas = new List <Pizza> {
                small, medium, large
            };
            PrintPizzaPrices(pizzas);

            small  = new ChiliSauce(small);
            pizzas = new List <Pizza> {
                small
            };
            PrintPizzaPrices(pizzas);
        }