Esempio n. 1
0
        public void HandleEvent(Event e)
        {
            switch (state)
            {
            case State.LOCKED:
                switch (e)
                {
                case Event.COIN:
                    state = State.UNLOCKED;
                    turnstileController.Unlock();
                    break;

                case Event.PASS:
                    turnstileController.Alarm();
                    break;
                }
                break;

            case State.UNLOCKED:
                switch (e)
                {
                case Event.COIN:
                    turnstileController.Thankyou();
                    break;

                case Event.PASS:
                    state = State.LOCKED;
                    turnstileController.Lock();
                    break;
                }
                break;
            }
        }
Esempio n. 2
0
    public void Event(int e)
    {
        switch (state)
        {
        case LOCKED:
            switch (e)
            {
            case COIN:
                state = UNLOCKED;
                controller.Unlock();
                break;

            case PASS:
                controller.Alarm();
                break;
            }
            break;

        case UNLOCKED:
            switch (e)
            {
            case COIN:
                controller.Thankyou();
                break;

            case PASS:
                state = LOCKED;
                controller.Lock();
                break;
            }
            break;
        }
    }
Esempio n. 3
0
        public StateTransitionTableTurnstile(TurnstileController controller)
        {
            Action unlock     = () => controller.Unlock();
            Action alarm      = () => controller.Alarm();
            Action thankYou   = () => controller.Thankyou();
            Action lockAction = () => controller.Lock();

            AddTransition(TurnstileState.LOCKED, TurnstileEvent.COIN, TurnstileState.UNLOCKED, unlock);
            AddTransition(TurnstileState.LOCKED, TurnstileEvent.PASS, TurnstileState.LOCKED, alarm);
            AddTransition(TurnstileState.UNLOCKED, TurnstileEvent.COIN, TurnstileState.UNLOCKED, thankYou);
            AddTransition(TurnstileState.UNLOCKED, TurnstileEvent.PASS, TurnstileState.LOCKED, lockAction);
        }
Esempio n. 4
0
            public void HandleEvent(Event e)
            {
                switch (state)
                {
                case State.Locked:
                    switch (e)
                    {
                    case Event.Coin:
                        state = State.Unlocked;
                        turnstileController.Unlock();
                        break;

                    case Event.Pass:
                        turnstileController.Alarm();
                        break;

                    default:
                        break;
                    }
                    break;

                case State.Unlocked:
                    switch (e)
                    {
                    case Event.Coin:
                        turnstileController.Sucker();
                        break;

                    case Event.Pass:
                        state = State.Locked;
                        turnstileController.Lock();
                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    break;
                }
            }
Esempio n. 5
0
 internal void Lock()
 {
     turnstileController.Lock();
 }
 public override void Lock()
 {
     controller.Lock();
 }
Esempio n. 7
0
 public void Lock()
 {
     turnstileController.Lock();
 }