public override ProductPizza CreatePizza(string item) { ProductPizza pizza = null; IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory(); if (item.Equals("Cheese")) { pizza = new CheesePizza(ingredientFactory); pizza.Name = "New York Style Cheese Pizza"; Console.WriteLine("Iftekhar odered a " + pizza.Name); pizza.Prepare(); } else if (item.Equals("Veggie")) { pizza = new VeggiePizza(ingredientFactory); pizza.Name = "New York Style Veggie Pizza"; pizza.Prepare(); } else if (item.Equals("Clam")) { pizza = new ClamPizza(ingredientFactory); pizza.Name = "New York Style Clam Pizza"; pizza.Prepare(); } else if (item.Equals("Pepperoni")) { pizza = new PepperoniPizza(ingredientFactory); pizza.Name = "New York Style Pepperoni Pizza"; pizza.Prepare(); } return(pizza); }
protected override Pizza CreatePizza(string type) { Pizza pizza = null; var ingredientFactory = new NewYorkPizzaIngredientFactory(); switch (type) { case "cheese": pizza = new CheesePizza(ingredientFactory); pizza.Name = "New York Style Clam Pizza"; break; case "clam": pizza = new ClamPizza(ingredientFactory); pizza.Name = "New York Style Clam Pizza"; break; default: throw new ArgumentOutOfRangeException($"No pizza type \"{type}\" exists"); } pizza.Prepare(); pizza.Bake(); pizza.Cut(); pizza.Box(); return(pizza); }