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/pizzafactorymethod/pizza.d

58 lines
1.0 KiB
D

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