public void Dispense()
 {
     Console.WriteLine("You're a winner! You get two gumballs for your quarter");
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() == 0)
     {
         gumballMachine.SetState(gumballMachine.GetSoldOut());
     }
     else
     {
         gumballMachine.ReleaseBall();
         if (gumballMachine.GetCount() > 0)
         {
             gumballMachine.SetState(gumballMachine.GetNoQuarter());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs");
             gumballMachine.SetState(gumballMachine.GetSold());
         }
     }
 }
Exemple #2
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() > 0)
     {
         gumballMachine.SetState(gumballMachine.GetNoQuarter());
     }
     else
     {
         Console.WriteLine("Oops, out of gumballs");
         gumballMachine.SetState(gumballMachine.GetSoldOut());
     }
 }
        public void TurenCrank()
        {
            Console.WriteLine("You turned...");
            int winner = randomWinner.Next(0, 10);

            if ((winner == 0) && (gumballMachine.GetCount() > 1))
            {
                gumballMachine.SetState(gumballMachine.GetWinner());
            }
            else
            {
                gumballMachine.SetState(gumballMachine.GetSold());
            }
        }