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; } }
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; } }
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); }
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; } }
internal void Lock() { turnstileController.Lock(); }
public override void Lock() { controller.Lock(); }
public void Lock() { turnstileController.Lock(); }