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/templatemethod/barista/caffeinebeveragewithhook.d

37 lines
549 B
D
Raw Normal View History

2022-11-16 23:25:52 +00:00
module caffeinebeveragewithhook;
import std.stdio : writeln;
abstract class CaffeineBeverageWithHook
{
final void prepareRecipe()
{
boilWater();
brew();
pourInCup();
if (customerWantsCondiments())
{
addCondiments();
}
}
void brew();
void addCondiments();
void boilWater()
{
writeln("Boiling water");
}
void pourInCup()
{
writeln("Pouring into cup");
}
bool customerWantsCondiments()
{
return true;
}
}