Lift Button

Write the brains of a lift button. When you press the button, the light comes on. When the lift arrives and the doors open, the light goes out. Pressing the button again while the light is on but the lift doors are closed has no effect. While the doors are open, pressing the button does not switch the light on.

This is a state diagram:

Lift Button State Diagram


This kata was invented by Olof Bjarnason

Referenced in these Learning Hours: