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/soldoutstate.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";
}
}