Week 2

  1. Compile Lights.java and TrafficLights.java.
  2. Run Lights as a Java application. (If possible do all this within Eclipse, although this is not essential)
  3. In America, the lights go straight from red to green (ie there is no intermediate red-amber step). Alter the code to do this. AmericanLights.java
  4. Add another button which switches off all the lights. (you may need to use the getSource() method in your actionPerformed method to find out which of the buttons was pressed. LightsClearButton.java
  5. Add a button which changes the size of the lights each time it is pressed. (Harder) LightsClearAndSizeButton.java
  6. Think about how to change the size of the lights with a slider. Look up on the web about how to use JSliders. LightsSlider.java



s.danicic@gold.ac.uk
Sebastian Danicic BSc MSc PhD (Reader in Computer Science)
Dept of Computing, Goldsmiths, University of London, London SE14 6NW
Last updated 2015-09-04