Example #1
0
        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();
                }
            }
        }
Example #2
0
 public void Dispense()
 {
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.GetBallCount() == 0)
     {
         Console.WriteLine("Oops, out of gumballs");
         _gumballMachine.SetSoldOutState();
     }
     else
     {
         _gumballMachine.SetNoQuarterState();
     }
 }