public Pizza CreatePizza(string type)
        {
            Pizza pizza = null;

            switch (type)
            {
            case "cheese":
                pizza = new CheesePizza();
                break;

            case "pepperoni":
                pizza = new PepperoniPizza();
                break;

            case "clam":
                pizza = new ClamPizza();
                break;

            case "veggie":
                pizza = new VeggiePizza();
                break;
            }
            Console.WriteLine(pizza);
            return(pizza);
        }
示例#2
0
 public Pizza CreatePizza(string type)
 {
     Pizza pizza = null;
     switch (type)
     {
         case "cheese": pizza = new CheesePizza(); break;
         case "pepperoni": pizza = new PepperoniPizza(); break;
         case "clam": pizza = new ClamPizza(); break;
         case "veggie": pizza = new VeggiePizza(); break;
     }
     Console.WriteLine(pizza);
     return pizza;
 }