public void Dispense() { gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() > 0) { gumballMachine.SetState(gumballMachine.GetNoQuarterState()); } else { Console.WriteLine("Ooops , out of gumballs"); gumballMachine.SetState(gumballMachine.GetsoldOutState()); } }
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()); } } }
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()); }
public void Report() { Console.WriteLine($"Gumball Machine:{machine.GetLocation()}"); Console.WriteLine($"Gumball Inventory:{machine.GetCount()}"); Console.WriteLine($"Gumball State:{machine.GetState()}"); }