Example #1
0
        /// <summary>
        /// This subclass handles object instantiation for us in the createPizza() method
        /// Encapsulates all the knowledge about how to make NY style pizzas
        /// </summary>
        public override Pizza createPizza(string type)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory =
                new NYPizzaIngredientFactory();

            if (type == "cheese")
            {
                pizza = new CheesePizza(ingredientFactory);
                pizza.setName("NY Style Cheese Pizza.");
            }
            else if (type == "veggie")
            {
                pizza = new VeggiePizza(ingredientFactory);
                pizza.setName("NY Style Veggie Pizza.");
            }
            else if (type == "clam")
            {
                pizza = new ClamPizza(ingredientFactory);
                pizza.setName("NY Style Clam Pizza.");
            }
            else if (type == "pepperoni")
            {
                pizza = new PepperoniPizza(ingredientFactory);
                pizza.setName("NY Style Pepperoni Pizza.");
            }
            return(pizza);
        }
Example #2
0
        public override Pizza createPizza(String item)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory =
                new ChicagoPizzaIngredientFactory();

            if (item.Equals("cheese"))
            {
                pizza = new CheesePizza(ingredientFactory);
                pizza.setName("Chicago Style Cheese Pizza");
            }
            else if (item.Equals("veggie"))
            {
                pizza = new VeggiePizza(ingredientFactory);
                pizza.setName("Chicago Style Veggie Pizza");
            }
            else if (item.Equals("clam"))
            {
                pizza = new ClamPizza(ingredientFactory);
                pizza.setName("Chicago Style Clam Pizza");
            }
            else if (item.Equals("pepperoni"))
            {
                pizza = new PepperoniPizza(ingredientFactory);
                pizza.setName("Chicago Style Pepperoni Pizza");
            }
            return(pizza);
        }
Example #3
0
        public override Pizza createPizza(string type)
        {
            ingredientFactory = new ChicagoPizzaIngredientFactory();

            if (type.Equals("Cheese"))
            {
                pizza = new CheesePizza(ingredientFactory);
                pizza.setName("Chicago Style Cheese Pizza");
            }
            else if (type.Equals("Clam"))
            {
                pizza = new ClamPizza(ingredientFactory);
                pizza.setName("Chicago Style Clam Pizza");
            }
            return(pizza);
        }
Example #4
0
        public override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;
            IIngredientsFactory ingredientsFactory = new NYPizzaIngredientFactory();

            switch (type)
            {
            case "Cheese":
                pizza = new CheesePizza(ingredientsFactory);
                pizza.setName("NY Style Cheese Pizza");
                break;

            case "Clam":
                pizza = new ClamPizza(ingredientsFactory);
                pizza.setName("NY Style Clam Pizza");
                break;

            default:
                Console.WriteLine("Please select valid pizza type.");
                break;
            }
            return(pizza);
        }