OO Programming in Java

Quiz


Lighting Problem



The Problem:

Mr. Wizzo's child always stayed up past his bedtime with his light on. Mr. Wizzo being an engineer said

"This is really an engineering problem so I will design something to help my son get to bed on time".

The plan was this:

Two sets of switches will control the light in the child's room. One set of switches is in the parent's room the other set is in the child's room. The parent's switches always have an effect on the light. The switches in the child's room have an effect only if the parent has pressed the "Release" button.

If the child has the light on in his room and the parent presses the "Off" button the light will turn off and the child's switches will have no further effect until the parent presses the "Release" key. Once the "Release" button is pressed the child has full control of his light again.

Help Mr. Wizzo out. .... Design a state machine to encapsulate the behavior indicated above..

State Machine Solution

See your class notes.



State Machine Java Implementation