Beispiel #1
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;
        }
    }
Beispiel #2
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;
            }
        }
Beispiel #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);
        }
Beispiel #4
0
 internal void Thankyou()
 {
     turnstileController.Thankyou();
 }
 public override void Thankyou()
 {
     controller.Thankyou();
 }