patterns/factorymethod/pizzasimple/simplepizzafactory.d

34 lines
780 B
D
Raw Normal View History

2022-12-05 07:38:19 +00:00
module factorymethod.pizzasimple.simplepizzafactory;
import factorymethod.pizzasimple.pizza;
import factorymethod.pizzasimple.cheesepizza;
import factorymethod.pizzasimple.pepperonipizza;
import factorymethod.pizzasimple.clampizza;
import factorymethod.pizzasimple.veggiepizza;
class SimplePizzaFactory
{
Pizza createPizza(string type)
{
Pizza pizza = null;
if (type == "cheese")
{
pizza = new CheesePizza();
}
else if (type == "pepperoni")
{
pizza = new PepperoniPizza();
}
else if (type == "clam")
{
pizza = new ClamPizza();
}
else if (type == "veggie")
{
pizza = new VeggiePizza();
}
return pizza;
}
}