Data Structures - Chapter 8 - Programming Assignment
Traffic Light Simulation

Data Structures and Other Objects Using C++


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 function called traffic which does the simulation.
Purposes:
Give you practice in using the Queue class.
Give you practice in reading header files and using classes that are written by someone else.
Before Starting:
Read all of Chapter 8--especially the car wash program in Section 8.2.
Due Date:
________________
Files that you must write:
  1. traffic.cxx: This is the main program for the traffic light simulation. You can start with the version in ~main2270/programs/traffic.cxx 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 traffic function. THe algorithm for the traffic function will be discussed in class. You'll also discuss what kind of results to expect from the simulation.
  2. makefile: This is a makefile for the assignment. The file should contain targets for things.o, traffic.o and traffic (an executable file). The source code things.cxx is available in the locations listed below. Your makefile should also include "all" and "clean" options--but there is no target for the Queue template class!
Other files that you may find helpful:
  1. queue2.h and queue2.template: My implementation of the Queue class. Notice that this version includes a peek() member function to get a copy of the front item without removing it.
  2. things.h and things.cxx: A collection of useful classes. You'll need to use the Averager, the BooleanSource, and the TrafficLight. (Some of these classes are from the car wash example of Section 8.2).

Traffic Light Synchronization
Discussion of the Assignment

Most of the information that you need for this assignment is in the traffic.cxx file. Some further discussion will be done in the Oct 13-14 tutorial groups.


Michael Main (main@colorado.edu)