module teawithhook; import std.stdio : write, writeln, readln; import std.uni : toLower; import std.algorithm : startsWith; import caffeinebeveragewithhook; class TeaWithHook : CaffeineBeverageWithHook { override void brew() { writeln("Steeping the tea"); } override void addCondiments() { writeln("Adding Lemon"); } override bool customerWantsCondiments() { if (getUserInput().toLower().startsWith("y")) { return true; } else { return false; } } string getUserInput() { string answer; write("Would you like lemon with your tea (y/n)? "); if ((answer = readln()) !is null) { return answer; } return "no"; } }