42 lines
774 B
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";
|
|
}
|
|
} |