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

51 lines
818 B
D

module factorymethod.pizzasimple.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("Подготовка " ~ name);
}
void bake()
{
writeln("Выпечка " ~ name);
}
void cut()
{
writeln("Резка " ~ name);
}
void box()
{
writeln("Упаковка " ~ name);
}
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;
}
}