Пример #1
0
        // Factory method implementation
        public override Pizza CreatePizza(string item)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory =
                new ChicagoPizzaIngredientFactory();

            switch (item)
            {
            case "cheese":
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "Chicago Style Cheese Pizza";
                break;

            case "veggie":
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.Name = "Chicago Style Veggie Pizza";
                break;

            case "clam":
                pizza      = new ClamPizza(ingredientFactory);
                pizza.Name = "Chicago Style Clam Pizza";
                break;

            case "pepperoni":
                pizza      = new PepperoniPizza(ingredientFactory);
                pizza.Name = "Chicago Style Pepperoni Pizza";
                break;
            }
            return(pizza);
        }
Пример #2
0
        public override Pizza CreatePizza(string item)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory =
                new NewYorkPizzaIngredientFactory();

            switch (item)
            {
                case "cheese":
                    pizza = new CheesePizza(ingredientFactory);
                    pizza.Name = "New York Style Cheese Pizza";
                    break;
                case "veggie":
                    pizza = new VeggiePizza(ingredientFactory);
                    pizza.Name = "New York Style Veggie Pizza";
                    break;
                case "clam":
                    pizza = new ClamPizza(ingredientFactory);
                    pizza.Name = "New York Style Clam Pizza";
                    break;
                case "pepperoni":
                    pizza = new PepperoniPizza(ingredientFactory);
                    pizza.Name = "New York Style Pepperoni Pizza";
                    break;
            }
            return pizza;
        }