示例#1
0
 public AtmStateMachine(Money cash)
 {
     _currentState = Initial = new InitialState(this);
     CardInserted  = new CardInserted(this);
     PinEntered    = new PinEntered(this);
     CashWithdrawn = new CashWithdrawn(this);
     CashAmount    = cash;
 }
        public void EjectDebitCard()
        {
            AtmMachineState.EjectDebitCard();

            // Debit Card has been ejected so internal state of ATM Machine
            // has been changed to 'DebitCardNotInsertedState'

            if (AtmMachineState is DebitCardInsertedState)
            {
                AtmMachineState = new DebitCardNotInsertedState();
                Console.WriteLine("ATM Machine internal state has been moved to : "
                                  + AtmMachineState.GetType().Name);
            }
        }
示例#3
0
 public void SetState(IAtmState newState)
 {
     _currentState = newState;
 }
 public AtmMachine()
 {
     AtmMachineState = new DebitCardNotInsertedState();
 }