public void Dispense()
        {
            _gumballMachine.ReleaseBall();
            bool noGumballs = false;

            if (_gumballMachine.Count > 0)
            {
                _gumballMachine.ReleaseBall();
                Console.WriteLine("YOU'RE A WINNER! You've got two gumballs for your quarter.");
                if (_gumballMachine.Count > 0)
                {
                    _gumballMachine.SetState(_gumballMachine.NoQuarterState);
                }
                else
                {
                    noGumballs = true;
                }
            }
            else
            {
                noGumballs = true;
            }

            if (noGumballs)
            {
                Console.WriteLine("Oops, out of gumballs!");
                _gumballMachine.SetState(_gumballMachine.SoldOutState);
            }
        }
Exemplo n.º 2
0
 public void Dispense()
 {
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.Count > 0)
     {
         _gumballMachine.SetState(_gumballMachine.NoQuarterState);
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs!");
         _gumballMachine.SetState(_gumballMachine.SoldOutState);
     }
 }
Exemplo n.º 3
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarter returned.");
     _gumballMachine.SetState(_gumballMachine.NoQuarterState);
 }
Exemplo n.º 4
0
 public void InsertQuarter()
 {
     Console.WriteLine("You inserted a quarter.");
     _gumballMachine.SetState(_gumballMachine.HasQuarterState);
 }
 public void Refill()
 {
     _gumballMachine.SetState(_gumballMachine.NoQuarterState);
 }