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