patterns/abstractfactory/nypizzastore.d

44 lines
1.2 KiB
D

module abstractfactory.nypizzastore;
import abstractfactory.pizza;
import abstractfactory.pizzastore;
import abstractfactory.pizzaingredientfactory;
import abstractfactory.nypizzaingredientfactory;
import abstractfactory.cheesepizza;
import abstractfactory.veggiepizza;
import abstractfactory.clampizza;
import abstractfactory.pepperonipizza;
class NYPizzaStore : PizzaStore
{
protected:
override Pizza createPizza(string item)
{
Pizza pizza;
PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();
if (item == "cheese")
{
pizza = new CheesePizza(ingredientFactory);
pizza.setName("New York Style Cheese Pizza");
}
else if (item == "veggie")
{
pizza = new VeggiePizza(ingredientFactory);
pizza.setName("New York Style Veggie Pizza");
}
else if (item == "clam")
{
pizza = new ClamPizza(ingredientFactory);
pizza.setName("New York Style Clam Pizza");
}
else if (item == "pepperoni")
{
pizza = new PepperoniPizza(ingredientFactory);
pizza.setName("New York Style Pepperoni Pizza");
}
return pizza;
}
}