This repository has been archived on 2022-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
patterns/abstractfactory/chicagopizzastore.d

44 lines
1.2 KiB
D
Raw Normal View History

2022-11-13 00:59:35 +00:00
module abstractfactory.chicagopizzastore;
import abstractfactory.pizza;
import abstractfactory.pizzastore;
import abstractfactory.pizzaingredientfactory;
import abstractfactory.chicagopizzaingredientfactory;
import abstractfactory.cheesepizza;
import abstractfactory.veggiepizza;
import abstractfactory.clampizza;
import abstractfactory.pepperonipizza;
class ChicagoPizzaStore : PizzaStore
{
protected:
override Pizza createPizza(string item)
{
Pizza pizza;
PizzaIngredientFactory ingredientFactory = new ChicagoPizzaIngredientFactory();
if (item == "cheese")
{
pizza = new CheesePizza(ingredientFactory);
pizza.setName("Chicago Style Cheese Pizza");
}
else if (item == "veggie")
{
pizza = new VeggiePizza(ingredientFactory);
pizza.setName("Chicago Style Veggie Pizza");
}
else if (item == "clam")
{
pizza = new ClamPizza(ingredientFactory);
pizza.setName("Chicago Style Clam Pizza");
}
else if (item == "pepperoni")
{
pizza = new PepperoniPizza(ingredientFactory);
pizza.setName("Chicago Style Pepperoni Pizza");
}
return pizza;
}
}