protected override PizzaBase CreatePizza(PizzaType type) { PizzaBase pizza = null; IPizzaIngredientFactory factory = new ChicagoPizzaIngredientFactory(); switch (type) { case PizzaType.Cheese: { pizza = new CheesePizza(factory); pizza.SetName("Chicago Style Cheese Pizza"); break; } case PizzaType.Pepperoni: { pizza = new PepperoniPizza(factory); pizza.SetName("Chicago Style Pepperoni Pizza"); break; } case PizzaType.Special: { pizza = new CurrentSpecialPizza(factory); pizza.SetName("Chicago Pizza Special!"); break; } default: throw new ArgumentException("Invalid Pizza type given"); } return(pizza); }
protected override Pizza CreatePizza(string pizzaType) { IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); Pizza pizza = null; switch (pizzaType) { case "cheese": pizza = new CheesePizza(ingredientFactory) { Name = "Chicago-Style Cheese" }; break; case "clam": pizza = new ClamPizza(ingredientFactory) { Name = "Chicago-Style Clam" }; break; default: break; } return(pizza); }
protected override Pizza CreatePizza(string item) { Pizza pizza = null; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (item.Equals(PizzaIngredientFactoryConstants.CHEESE_PIZZA)) { pizza = new CheesePizza(ingredientFactory); pizza.SetName("Chicago Style Cheese Pizza"); } else if (item.Equals(PizzaIngredientFactoryConstants.VEGGIE_PIZZA)) { pizza = new VeggiePizza(ingredientFactory); pizza.SetName("Chicago Style Veggie Pizza"); } else if (item.Equals(PizzaIngredientFactoryConstants.CLAM_PIZZA)) { pizza = new ClamPizza(ingredientFactory); pizza.SetName("Chicago Style Clam Pizza"); } else if (item.Equals(PizzaIngredientFactoryConstants.PEPPERONI_PIZZA)) { pizza = new PepperoniPizza(ingredientFactory); pizza.SetName("Chicago Style Pepperoni Pizza"); } return(pizza); }
public override Pizza CreatePizza(string pizzaType) { Pizza pizza = null; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (pizzaType) { case "cheese": pizza = new CheesePizza(ingredientFactory); pizza.SetName("Chicago Style Deep Dish Cheese Pizza"); break; case "veggie": pizza = new VeggiePizza(ingredientFactory); pizza.SetName("Chicago Style Deep Dish Veggie Pizza"); break; case "clam": pizza = new ClamPizza(ingredientFactory); pizza.SetName("Chicago Style Deep Dish Clam Pizza"); break; case "pepperoni": pizza = new PepperoniPizza(ingredientFactory); pizza.SetName("Chicago Style Deep Dish Pepperoni Pizza"); break; } return(pizza); }
protected override PizzaBase CreatePizza(string type) { PizzaBase pizza = null; ChicagoPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (type) { case "cheese": pizza = new CheesePizza(ingredientFactory) { Name = "Chicago Style Cheese Pizza" }; break; case "clam": pizza = new ClamPizza(ingredientFactory) { Name = "Chicago Style Clam Pizza" }; break; default: return(null); } return(pizza); }
protected override Pizza createPizza(string type) { var ingredientFactory = new ChicagoPizzaIngredientFactory(); Pizza pizza = null; var pizzaType = type.ToLower(); switch (pizzaType) { case "cheese": pizza = new CheesePizza(ingredientFactory); pizza.Name = "Chicago Style Cheese Pizza"; break; case "pepperoni": pizza = new PepperoniPizza(ingredientFactory); pizza.Name = "Chicago Style Pepperoni Pizza"; break; case "clam": pizza = new ClamsPizza(ingredientFactory); pizza.Name = "Chicago Style Clam Pizza"; break; case "veggie": pizza = new VeggiePizza(ingredientFactory); pizza.Name = "Chicago Style Veggie Pizza"; break; } return(pizza); }
protected override Pizza.Pizza CreatePizza(String item) { Pizza.Pizza pizza; IPizzaIngredientFactory pizzaIngredientFactory = new ChicagoPizzaIngredientFactory(); switch (item) { case "cheese": { pizza = new CheesePizza(pizzaIngredientFactory); return(pizza); } case "clam": { pizza = new ClamPizza(pizzaIngredientFactory); return(pizza); } default: { return(null); } } }
protected override Pizza CreatePizza(string type) { Pizza pizza; var ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (type) { case "cheese": pizza = new CheesePizza(ingredientFactory); pizza.SetName("New York Style Cheese Pizza"); break; case "clam": pizza = new ClamPizza(ingredientFactory); pizza.SetName("New York Style Clam Pizza"); break; case "veggie": pizza = new VeggiePizza(ingredientFactory); pizza.SetName("New York Style Veggie Pizza"); break; case "pepperoni": pizza = new PepperoniPizza(ingredientFactory); pizza.SetName("New York Style Pepperoni Pizza"); break; default: pizza = null; break; } return(pizza); }
protected override Pizza CreatePizza(PizzaType pizzaType) { Pizza pizza = null; var pizzaIngredientFactory = new ChicagoPizzaIngredientFactory(); switch (pizzaType) { case PizzaType.Cheese: pizza = new ChicagoCheesePizza(pizzaIngredientFactory); break; case PizzaType.Pepperoni: pizza = new ChicagoPepperoniPizza(pizzaIngredientFactory); break; case PizzaType.Clam: pizza = new ChicagoClamPizza(pizzaIngredientFactory); break; case PizzaType.Veggie: pizza = new ChicagoVeggiePizza(pizzaIngredientFactory); break; } return(pizza); }
protected internal override Pizza CreatePizza(string item) { Pizza pizza = null; PizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (item.Equals("cheese")) { pizza = new CheesePizza(ingredientFactory); pizza.Name = "Chicago Style Cheese Pizza"; } else if (item.Equals("veggie")) { pizza = new VeggiePizza(ingredientFactory); pizza.Name = "Chicago Style Veggie Pizza"; } else if (item.Equals("clam")) { pizza = new ClamPizza(ingredientFactory); pizza.Name = "Chicago Style Clam Pizza"; } else if (item.Equals("pepperoni")) { pizza = new PepperoniPizza(ingredientFactory); pizza.Name = "Chicago Style Pepperoni Pizza"; } return(pizza); }
protected override Pizza CreatePizza(string type) { Pizza pizza = null; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (type == "cheese") { pizza = new CheesePizza(ingredientFactory); pizza.Name = "Chicago Style Cheese Pizza"; } else if (type == "pepperoni") { pizza = new VeggiePizza(ingredientFactory); pizza.Name = "Chicago Style Veggie Pizza"; } else if (type == "clam") { pizza = new ClamPizza(ingredientFactory); pizza.Name = "Chicago Style Clam Pizza"; } else if (type == "veggie") { pizza = new VeggiePizza(ingredientFactory); pizza.Name = "Chicago Style Veggie Pizza"; } return(pizza); }
protected override Pizza createPizza(string item) { Pizza pizza = null; // Фабрика производит ингредиенты для всех пицц в Чикаго стиле IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (item.Equals("cheese")) { pizza = new CheesePizza(ingredientFactory); pizza.name = "Чикагская с сыром"; } else if (item.Equals("veggie")) { pizza = new VeggiePizza(ingredientFactory); pizza.name = "Чикагская Вегетарианская"; } else if (item.Equals("clam")) { pizza = new ClamPizza(ingredientFactory); pizza.name = "Чикагская с мидиями"; } else if (item.Equals("pepperoni")) { pizza = new PepperoniPizza(ingredientFactory); pizza.name = "Чикагская Пепперони"; } return(pizza); }
/// <summary> /// This subclass handles object instantiation for us in the createPizza() method /// Encapsulates all the knowledge about how to make Chicago style pizzas /// </summary> public override Pizza createPizza(string type) { Pizza pizza = null; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (type == "cheese") { pizza = new CheesePizza(ingredientFactory); pizza.setName("Chicago Style Cheese Pizza."); } else if (type == "veggie") { pizza = new VeggiePizza(ingredientFactory); pizza.setName("Chicago Style Veggie Pizza."); } else if (type == "clam") { pizza = new ClamPizza(ingredientFactory); pizza.setName("Chicago Style Clam Pizza."); } else if (type == "pepperoni") { pizza = new PepperoniPizza(ingredientFactory); pizza.setName("Chicago Style Pepperoni Pizza."); } return(pizza); }
protected override Pizza CreatePizza(string type) { Pizza pizza = null; PizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (type) { case PizzaType.CHEESE: pizza = new CheesePizza(ingredientFactory); pizza.Name = "Chicago Cheese Pizza"; break; case PizzaType.CLAM: pizza = new ClamPizza(ingredientFactory); pizza.Name = "Chicago Clam Pizza"; break; case PizzaType.PEPPERONI: pizza = new PepperoniPizza(ingredientFactory); pizza.Name = "Chicago Pepperoni Pizza"; break; case PizzaType.VEGGIE: pizza = new VeggiePizza(ingredientFactory); pizza.Name = "Chicago Veggie Pizza"; break; default: throw new ArgumentException(String.Format("Unkonown Pizza Type '{0}'", type)); } return(pizza); }
public override Pizza CreatePizza(PizzaType pizzaType) { Pizza pizza = null; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (pizzaType == PizzaType.Cheese) { pizza = new CheesePizza(ingredientFactory); } else if (pizzaType == PizzaType.Veggie) { pizza = new VeggiePizza(ingredientFactory); } else if (pizzaType == PizzaType.Pepperoni) { pizza = new PepperoniPizza(ingredientFactory); } else if (pizzaType == PizzaType.Clam) { pizza = new ClamPizza(ingredientFactory); } return(pizza); }
protected override Pizza CreatePizza(string item) { Pizza pizza = null; var ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (item) { case "cheese": pizza = new CheesePizza(ingredientFactory); pizza.Name = "Chicago Style Cheese Pizza"; break; case "pepperoni": pizza = new PepperoniPizza(ingredientFactory); pizza.Name = "Chicago Style Pepperoni Pizza"; break; case "clam": pizza = new ClamPizza(ingredientFactory); pizza.Name = "Chicago Style Clam Pizza"; break; case "veggie": pizza = new VeggiePizza(ingredientFactory); pizza.Name = "Chicago Style Veggie Pizza"; break; } return(pizza); }
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); }
public override Pizza CreatePizza(PizzaType type) { Pizza pizza; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (type) { case PizzaType.Cheese: pizza = new CheesePizza(ingredientFactory) { Name = "Chicago Style Cheese Pizza" }; break; case PizzaType.Clam: pizza = new ClamPizza(ingredientFactory) { Name = "Chicago Style Clam Pizza" }; break; case PizzaType.Veggie: case PizzaType.Pepperoni: default: throw new ArgumentException("Wrong type of pizza"); } return(pizza); }
protected override Pizza createPizza(string item) { Pizza pizza = null; PizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (item.Equals("cheese")) { pizza = new CheesePizza(ingredientFactory); pizza.setName("芝加哥风格芝士披萨"); } else if (item.Equals("veggie")) { pizza = new VeggiePizza(ingredientFactory); pizza.setName("芝加哥风格素食披萨"); } else if (item.Equals("clam")) { pizza = new ClamPizza(ingredientFactory); pizza.setName("芝加哥风格蛤蜊披萨"); } else if (item.Equals("pepperoni")) { pizza = new PepperoniPizza(ingredientFactory); pizza.setName("芝加哥风格意大利辣香肠披萨"); } return(pizza); }
protected override Pizza CreatePizza(PizzaType type) { var factory = new ChicagoPizzaIngredientFactory(); var behavior = new ChicagoPizzaCookBehavior(); switch (type) { case PizzaType.Cheese: return(new CheesePizza(factory, behavior) { Name = "Chicago Cheese Pizza" }); case PizzaType.Clam: return(new ClamPizza(factory, behavior) { Name = "Chicago Clam Pizza" }); case PizzaType.Pepperoni: return(new PepperoniPizza(factory, behavior) { Name = "Chicago Pepperoni Pizza" }); case PizzaType.Veggie: return(new VeggiePizza(factory, behavior) { Name = "Chicago Veggie Pizza" }); default: throw new ArgumentException(); } }
public void ChicagoIngredientFactory() { var factory = new ChicagoPizzaIngredientFactory(); Assert.IsTrue(factory.CreateCheese() is ReggianoCheese); Assert.IsTrue(factory.CreateClam() is FrozenClam); Assert.IsTrue(factory.CreateSauce() is PlumTomatoSauce); Assert.IsTrue(factory.CreateDough() is ThickCrustDough); }
protected override Pizza CreatePizza(PizzaType pizzaType) { IPizzaIngredientFactory pizzaIngredientFactory = new ChicagoPizzaIngredientFactory(); string style = "Chicago Style"; switch (pizzaType) { case PizzaType.Clam: return(new ClamPizza(style, pizzaIngredientFactory)); case PizzaType.Veggie: return(new VeggiePizza(style, pizzaIngredientFactory)); case PizzaType.Cheese: default: return(new CheesePizza(style, pizzaIngredientFactory)); } }
protected override Pizza createPizza(string type) { IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (type) { case "cheese": return(new ChicagoStyleCheesePizza(ingredientFactory)); case "pepperoni": return(new ChicagoStylePepperoniPizza(ingredientFactory)); case "vegan": return(new ChicagoStyleVeganPizza(ingredientFactory)); default: throw new ArgumentException("Incorrect type of pizza"); } }
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); }
protected override Pizza CreatePizza(string type) { Pizza pizza = null; IPizzaIngredientFactory 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); }
protected override Pizza CreatePizza(string type) { Pizza pizza = null; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (type.Equals("cheese")) { pizza = new CheesePizza(ingredientFactory); pizza.Name = "Chicago Style Cheese Pizza"; } // cheese else { WriteLine("{0}: Don't know how to create {1} pizza", this.GetType().ToString(), type); throw new System.NotImplementedException(type); } // unknown pizza type return(pizza); } // PizzaStore.CreatePizza
protected override Pizza CreatePizza(PizzaType type) { IPizzaIngredientFactory ingredient = new ChicagoPizzaIngredientFactory(); switch (type) { case PizzaType.Cheese: { Pizza pizza = new CheesePizza(ingredient); pizza.Name = "Chicago style Cheese Pizza"; return pizza; } default: { return null; } } }
static void Main(string[] args) { IPizzaIngredientFactory nyPizzaIngredientFactory = new NYPizzaIngredientFactory(); IPizzaIngredientFactory chicagoPizzaIngredientFactory = new ChicagoPizzaIngredientFactory(); PizzaStore nyPizzaStore = new NYPizzaStore(nyPizzaIngredientFactory); PizzaStore chicagoPizzaStore = new ChicagoPizzaStore(chicagoPizzaIngredientFactory); Pizza nyPizza = nyPizzaStore.OrderPizza("cheese"); Console.WriteLine( $"Name: {nyPizza.Name}, Dough: {nyPizza.Dough}, Sauce: {nyPizza.Sauce}, Cheese: {nyPizza.Cheese}, Clams: {nyPizza.Clams}"); Pizza chicagoPizza = chicagoPizzaStore.OrderPizza("cheese"); Console.WriteLine( $"Name: {chicagoPizza.Name}, Dough: {chicagoPizza.Dough}, Sauce: {chicagoPizza.Sauce}, Cheese: {chicagoPizza.Cheese}, Clams: {chicagoPizza.Clams}"); }
protected override Pizza CreatePizza(string type) { var factory = new ChicagoPizzaIngredientFactory(); Pizza pizza = null; switch (type) { case "cheese": pizza = new CheesePizza(factory); pizza.Name = "Chicago Cheese Pizza"; break; case "clams": pizza = new ClamsPizza(factory); pizza.Name = "Chicago Clams Pizza"; break; } return(pizza); }
public override Pizza CreatePizza(PizzaType type) { Pizza pizza = null; IPizzaIngredientsFactory factory = new ChicagoPizzaIngredientFactory(); switch (type) { case PizzaType.Cheese: pizza = new CheesePizza(factory) { Name = "Chicago Cheese Pizza" }; break; case PizzaType.Clam: pizza = new ClamPizza(factory) { Name = "Chicago Clam Pizza" }; break; } return(pizza); }
protected override PizzaAbstract CreatePizza(string type) { PizzaAbstract pizza = null; PizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); if (type.Equals("cheese")) { pizza = new CheesePizza(ingredientFactory); pizza.SetName("Pizza de Queijo no Estilo de Chicago"); } else if (type.Equals("clam")) { pizza = new ClamPizza(ingredientFactory); pizza.SetName("Pizza de Mariscos no Estilo de Chicago"); } return(pizza); }
protected override Pizza CreatePizza(string type) { Pizza pizza = null; IPizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory(); switch (type) { case "cheese": pizza = new CheesePizza(ingredientFactory); pizza.Name = "Chicago Style Cheese 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; }