示例#1
0
        static void Main(string[] args)
        {
            Pizza pizza = new LargePizza();

            pizza = new Cheese(pizza);
            pizza = new Ham(pizza);


            Console.WriteLine($"{pizza.GetDescription()} that have a cost of {pizza.CalculateCost()}");
        }
示例#2
0
        static void Main(string[] args)
        {
            Pizza largePizza = new LargePizza();

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


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

            Console.ReadKey();
        }