Пример #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
        // 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;
        }