예제 #1
0
        public override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;

            switch (type)
            {
            case "Cheese":
                pizza = new ChicagoStyleCheesePizza();
                break;

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

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

            case "veggie":
                pizza = new ChicagoStyleVeggiePizza();
                break;

            default:
                Console.WriteLine("default case");
                break;
            }

            return(pizza);
        }
예제 #2
0
        public override Pizza CreatePizza(string vsType)
        {
            Pizza oPizza = null;

            if (vsType == "cheese")
            {
                oPizza = new ChicagoStyleCheesePizza();
            }
            else if (vsType == "pepperoni")
            {
                oPizza = new ChicagoStylePepperoniPizza();
            }
            else if (vsType == "clam")
            {
                oPizza = new ChicagoStyleClamPizza();
            }
            else if (vsType == "veggie")
            {
                oPizza = new ChicagoStyleVeggiePizza();
            }
            else
            {
                // Should throw an exception
            }
            return(oPizza);
        }