module factorymethod.pizzafactorymethod.pizza; import std.stdio : writeln; abstract class Pizza { protected: string name; string dough; string sauce; string[] toppings; public: string getName() { return name; } void prepare() { writeln("Prepare " ~ name); writeln("Tossing dough..."); writeln("Adding sauce..."); writeln("Adding toppings: "); foreach (val; toppings) { writeln(" " ~ val); } } void bake() { writeln("Bake for 25 minutes at 350"); } void cut() { writeln("Cut the pizza into diagonal slices"); } void box() { writeln("Place pizza in official PizzaStore box"); } override string toString() const @safe pure nothrow { string s; s ~= "---- " ~ name ~ " ----\n"; s ~= dough ~ "\n"; s ~= sauce ~ "\n"; foreach (val; toppings) { s ~= val ~ '\n'; } return s; } }