// Выдаем два шарика public void Dispense() { gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() == 0) { gumballMachine.SetState(gumballMachine.GetSoldOutState()); } // Если в автомате есть второй шарик, освобождаем его else { Console.WriteLine("YOU'RE A WINNER! You got two gumballs for your quarter"); gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() > 0) { gumballMachine.SetState(gumballMachine.GetNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); gumballMachine.SetState(gumballMachine.GetSoldOutState()); } } }
public void Dispense() { gumballMachine.ReleaseBall(); if (gumballMachine.GetCount() > 0) { gumballMachine.SetState(gumballMachine.GetNoQuarterState()); } else { Console.WriteLine("Oops, out of gumballs!"); gumballMachine.SetState(gumballMachine.GetSoldOutState()); } }