GofPatterns GofPatterns

Structural Patterns  «Prev  Next»
Lesson 9 Course Project, part 5
ObjectiveWrite a Class that contains the vehicles currently backed up at the intersection

Class Vehicle Intersection

Each direction at the intersection has a queue of pedestrians, bicycles, cars, buses, and so forth. Ideally, the lights in each direction should be green long enough for the queue to empty out. Furthermore, the light should be green more often for the direction with more traffic. When this is the case, traffic flows smoothly. When it is not, you have got a traffic jam. One of the purposes of a simulation like this is to figure out what the optimal strategy is for turning the lights green and red.
For this part of the course project, you will concentrate on the vehicles that are queued at the intersection. You will need to create a VehicleQueue class that contains the vehicles.

An intersection is the junction at grade of two or more roads either meeting or crossing. An intersection may be
  1. three-way (a T junction or Y junction (the latter also known as a fork)),
  2. four-way (a crossroads), or
  3. have five or more arms.

Vehicle traffic at an intersection

Backedup Vehicles Intersection - Exercise

Now it is time to continue your course project.
Backedup Vehicles Intersection - Exercise