コード例 #1
0
        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);
        }
コード例 #2
0
        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
            });
        }
コード例 #3
0
 public void InsertNote(int nominal)
 {
     _owner.ChangeState <NotesInsertionState>(_cashRepository, _currency)
     .InsertNote(nominal);
 }