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/factorymethod/pizzasimple/simplepizzafactory.d

34 lines
780 B
D

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;
}
}