Beispiel #1
0
 public void Dispense()
 {
     _gumbalMachineContext.ReleaseBall();
     if (_gumbalMachineContext.BallsCount == 0)
     {
         Console.WriteLine("Oops, out of gumbals");
         _gumbalMachineContext.SetSoldOutState();
     }
     else if (_gumbalMachineContext.QuartersCount == 0)
     {
         _gumbalMachineContext.SetNoQuarterState();
     }
     else
     {
         _gumbalMachineContext.SetHasQuarterState();
     }
 }
Beispiel #2
0
 public void AddBalls(uint ballsCount)
 {
     Console.WriteLine($"We are have added {ballsCount} gumball{( ballsCount != 1 ? "s" : "" )}");
     _gumbalMachineContext.BallsCount += ballsCount;
     _gumbalMachineContext.SetNoQuarterState();
 }
Beispiel #3
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarters returned");
     _gumbalMachineContext.QuartersCount = 0;
     _gumbalMachineContext.SetNoQuarterState();
 }