public void dispense() { gumballMachine.releaseBall(); if (gumballMachine.getCount() > 0) { gumballMachine.setState(gumballMachine.getNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); gumballMachine.setState(gumballMachine.getSoldOutState()); } }
public void dispense() { Console.WriteLine("YOU'RE A WINNER! You get two gumballs for your quarter"); gumballMachine.releaseBall(); if (gumballMachine.getCount() == 0) { Console.WriteLine("Oops, out of gumballs!"); gumballMachine.setState(gumballMachine.getSoldOutState()); } else { gumballMachine.releaseBall(); if (gumballMachine.getCount() > 0) { gumballMachine.setState(gumballMachine.getNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); gumballMachine.setState(gumballMachine.getSoldOutState()); } } }
public void ejectQuarter() { Console.WriteLine("Quarter returned"); gumballMachine.setState(gumballMachine.getNoQuarterState()); }