Example #1
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() > 0)
     {
         gumballMachine.SetState(gumballMachine.GetNoQuarterState());
     }
     else
     {
         Console.WriteLine("Ooops , out of gumballs");
         gumballMachine.SetState(gumballMachine.GetsoldOutState());
     }
 }
Example #2
0
 public void Dispense()
 {
     Console.WriteLine("You are a winner!Two balls for your quarter");
     GumballMachine.ReleaseBall();
     if (GumballMachine.GetCount() == 0)
     {
         GumballMachine.SetState(GumballMachine.GetsoldOutState());
     }
     else
     {
         GumballMachine.ReleaseBall();
         if (GumballMachine.GetCount() > 0)
         {
             GumballMachine.SetState(GumballMachine.GetsoldOutState());
         }
         else
         {
             Console.WriteLine("Out of balls");
             GumballMachine.SetState(GumballMachine.GetsoldOutState());
         }
     }
 }
Example #3
0
        public void TurnCrank()
        {
            Console.WriteLine("You turned...");
            int winner = randomWinner.Next(10);

            if ((winner == 0) && (gumballMachine.GetCount() > 1))
            {
                gumballMachine.SetState(gumballMachine.GetWinnerState());
            }
            else
            {
                gumballMachine.SetState(gumballMachine.GetSoldState());
            }
            gumballMachine.SetState(gumballMachine.GetSoldState());
        }
Example #4
0
 public void Report()
 {
     Console.WriteLine($"Gumball Machine:{machine.GetLocation()}");
     Console.WriteLine($"Gumball Inventory:{machine.GetCount()}");
     Console.WriteLine($"Gumball State:{machine.GetState()}");
 }