Exemplo n.º 1
0
 public void TurnCrank()
 {
     _machine.ReleaseBall();
     if (_machine.GetCount() > 0)
     {
         _machine.SetState(_machine.GetNoQuarterState());
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs!");
         _machine.SetState(_machine.GetSoldOutState());
     }
 }
Exemplo n.º 2
0
 public void Dispense()
 {
     Console.WriteLine("You are a winner! You get two gumballs for your quarter");
     _machine.ReleaseBall();
     if (_machine.GetCount() == 0)
     {
         _machine.SetState(_machine.GetSoldOutState());
     }
     else
     {
         _machine.ReleaseBall();
         if (_machine.GetCount() > 0)
         {
             _machine.SetState(_machine.GetNoQuarterState());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs!");
             _machine.SetState(_machine.GetSoldOutState());
         }
     }
 }
        public void TurnCrank()
        {
            Console.WriteLine("You turned...");
            int winner = randomWinner.Next(1, 11);

            if (winner < 6 && _machine.GetCount() > 1)
            {
                _machine.SetState(_machine.GetWinnerState());
            }
            else
            {
                this._machine.SetState(_machine.GetSoldState());
            }
        }
 public void InsertQuarter()
 {
     Console.WriteLine("Insert Quarter Success");
     _machine.SetState(_machine.GetHasQuarterState());
 }