Sample Programming Assignment
Chapter 7
Traffic Light Simulation

The Assignment:
You will implement and test a small program that simulates two synchronized traffic lights. Some of the work has already been done--your primary job is to implement a method called simlights which does the simulation.
Purposes:
Give you practice in using the Queue class.
Give you practice in reading documentation and using classes that are written by someone else.
Before Starting:
Read all of Chapter 7--especially the car wash program in Section 7.2.
Files that you must write:
  1. Traffic.java: This is a Java application program for the traffic light simulation. You can start with the version in http://www.cs.colorado.edu/~main/applications/Traffic.java and add your name and other information at the top. You'll have to read and understand all of this program, and you'll implement the specified simlights method. The algorithm for the traffic method will be discussed in class. You'll also discuss what kind of results to expect from the simulation.
Other files that you may find helpful:
  1. The IntQueue Documentation
  2. The Averager Documentation
  3. The BooleanSource Documentation
  4. The TrafficLight Documentation

Traffic Light Synchronization
Discussion of the Assignment

Most of the information that you need for this assignment is in the Traffic.java file. Some further discussion will be done in class.


Michael Main (main@colorado.edu)