module coffeewithhook;

import std.stdio : write, writeln, readln;
import std.uni : toLower;
import std.algorithm : startsWith;
import caffeinebeveragewithhook;

class CoffeeWithHook : CaffeineBeverageWithHook
{
    override void brew()
    {
        writeln("Dripping Coffee through filter");
    }

    override void addCondiments()
    {
        writeln("Adding Sugar and Milk");
    }

    override bool customerWantsCondiments()
    {
        if (getUserInput().toLower().startsWith("y"))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    string getUserInput()
    {
        string answer;
        
        write("Would you like milk and sugar with your coffee (y/n)? ");

        if ((answer = readln()) !is null)
        {
            return answer;
        }

        return "no";
    }
}
