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/state/gumballmachinestate/noquarterstate.d

42 lines
774 B
D

module noquarterstate;
import std.stdio : writeln;
import state, gumballmachine;
class NoQuarterState : State
{
GumballMachine gumballMachine;
this(GumballMachine gumballMachine)
{
this.gumballMachine = gumballMachine;
}
void insertQuarter()
{
writeln("You inserted a quarter");
gumballMachine.setState(gumballMachine.getHasQuarterState());
}
void ejectQuarter()
{
writeln("You haven't inserted a quarter");
}
void turnCrank()
{
writeln("You turned, but there's no quarter");
}
void dispense()
{
writeln("You need to pay first");
}
void refill() { }
override string toString() const
{
return "waiting for quarter";
}
}