예제 #1
0
        public Pizza orderPizza(E_PizzaType type)
        {
            Pizza pizza = createPizza(type);

            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();

            return(pizza);
        }
        protected override Pizza createPizza(E_PizzaType type)
        {
            Pizza pizza;
            I_PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            switch (type)
            {
            case E_PizzaType.CHEESE_PIZZA:
                pizza           = new CheesePizza(ingredientFactory);
                pizza.pizzaType = type;
                pizza.name      = "New York Style Cheese Pizza";
                break;

            case E_PizzaType.PEPPERONI_PIZZA:
                pizza           = new PepperoniPizza(ingredientFactory);
                pizza.pizzaType = type;
                pizza.name      = "New York Style Pepperoni Pizza";
                break;

            case E_PizzaType.CLAM_PIZZA:
                pizza           = new ClamPizza(ingredientFactory);
                pizza.pizzaType = type;
                pizza.name      = "New York Style Clam Pizza";
                break;

            case E_PizzaType.VEGGIE_PIZZA:
                pizza           = new VeggiePizza(ingredientFactory);
                pizza.pizzaType = type;
                pizza.name      = "New York Style Veggie Pizza";
                break;

            default:
                pizza = null;
                break;
            }

            return(pizza);
        }
예제 #3
0
 protected abstract Pizza createPizza(E_PizzaType type);