Making the Traffic Light Responsive
In this example, we would like to make the individual lights on the traffic
light "clickable" so that clicking the mouse on a light will turn it on
(and turn off the light that is currently on). How do we need to change the
previous program to do this?
Here is a solution in the form of the class ChangeableTL.
A
driver that demonstrates how it works.
This is the
output after a few clicks.
However, it is also instructive to see the diagnostic output that is written
to System.out.