public void Dispense() { _gumballMachine.ReleaseBall(); _gumballMachine.GetQuartersController().UseQuarter(); if (_gumballMachine.GetBallCount() == 0) { Console.WriteLine("Oops, out of gumballs"); if (_gumballMachine.GetQuartersController().HasQuarters()) { Console.WriteLine("returning unused quarters"); _gumballMachine.GetQuartersController().EjectQuarters(); } _gumballMachine.SetSoldOutState(); } else { if (_gumballMachine.GetQuartersController().HasQuarters()) { _gumballMachine.SetHasQuarterState(); } else { _gumballMachine.SetNoQuarterState(); } } }
public void InsertQuarter() { try { _gumballMachine.GetQuartersController().InsertQuarter(); Console.WriteLine("You inserted a quarter"); _gumballMachine.SetHasQuarterState(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void EjectQuarters() { _gumballMachine.GetQuartersController().EjectQuarters(); Console.WriteLine("Quarter returned"); _gumballMachine.SetNoQuarterState(); }