public static TMachineState ChangeState <TMachineState>(this IMachineStateOwner owner, params object[] args) where TMachineState : IMachineState { TMachineState newState = CreateNewState <TMachineState>(owner, args); owner.ChangeState(newState); return(newState); }
public IExchangeResult Exchange() { var returnedMoney = MoneyCollection.Create(_currency); bool success = TryExchange(returnedMoney); if (success) { _cashRepository.RemoveMoney(returnedMoney); } _owner.ChangeState <FreshMachineState>(_cashRepository, _currency); return(new ExchangeResult { Success = success, Money = returnedMoney }); }
public void InsertNote(int nominal) { _owner.ChangeState <NotesInsertionState>(_cashRepository, _currency) .InsertNote(nominal); }