Beispiel #1
0
 public void Dispense()
 {
     Console.WriteLine("You're a winner! you get two gumballs for your quarter!!");
     GumballMachine.ReleaseBall();
     if (GumballMachine.Count == 0)
     {
         GumballMachine.CurrentState = GumballMachine.SoldOutState;
     }
     else
     {
         GumballMachine.ReleaseBall();
         if (GumballMachine.Count > 0)
         {
             GumballMachine.CurrentState = GumballMachine.NoQuarterState;
         }
         else
         {
             Console.WriteLine("Oops! out of gumballs");
             GumballMachine.CurrentState = GumballMachine.SoldOutState;
         }
     }
 }
Beispiel #2
0
        public void Dispense()
        {
            GumballMachine.ReleaseBall();

            if (GumballMachine.Count == 0)
            {
                Console.WriteLine("Out of gumballs");
                GumballMachine.CurrentState = GumballMachine.SoldOutState;
            }
            else
            {
                GumballMachine.CurrentState = GumballMachine.NoQuarterState;
            }
        }