public GumballMachineInfo(int num) { _count = num > 0 ? num : 0; if (_count > 0) { CurrentState = new NoQuarterState(this).GetCurrentState(); } else { CurrentState = new SoldOutState(this).GetCurrentState(); } }
public void Refill(int num) { if (CurrentState.StatusName == MarchineStatus.NoQuarterState || CurrentState.StatusName == MarchineStatus.SoldOutState) { _count += num; CurrentState = new NoQuarterState(this).GetCurrentState(); Console.WriteLine("The marchine refill " + num + " gumball"); } else { Console.WriteLine("You can't refill the marchine since the marchine is running"); } }