45 lines
819 B
D
45 lines
819 B
D
module soldoutstate;
|
|
|
|
import std.stdio : writeln;
|
|
import state, gumballmachine;
|
|
|
|
class SoldOutState : State
|
|
{
|
|
GumballMachine gumballMachine;
|
|
|
|
this(GumballMachine gumballMachine)
|
|
{
|
|
this.gumballMachine = gumballMachine;
|
|
}
|
|
|
|
void insertQuarter()
|
|
{
|
|
writeln("You can't insert a quarter, the machine is sold out");
|
|
}
|
|
|
|
void ejectQuarter()
|
|
{
|
|
writeln("You can't eject, you haven't inserted a quarter yet");
|
|
}
|
|
|
|
void turnCrank()
|
|
{
|
|
writeln("You turned, but there are no gumballs");
|
|
}
|
|
|
|
void dispense()
|
|
{
|
|
writeln("No gumball dispensed");
|
|
}
|
|
|
|
void refill()
|
|
{
|
|
gumballMachine.setState(gumballMachine.getNoQuarterState());
|
|
}
|
|
|
|
override string toString() const
|
|
{
|
|
return "sold out";
|
|
}
|
|
}
|