Suppose cars are in a line to leave a parking lot. If there is a space in front of a car, it can move forward. If there is no space, it must stay in place. This causes cars to creep forward a bit at a time until each has left th eparking lot. This pattern of movement can be described by a simple machine known as Rule 184. The underlying pattern is notable because it describes a number of patterns in nature. You can read about Rule 184 if you like, but that is not required for this assignment.
Your program will read a string capturing a line of vehicles moving left to
right. Vehicles consist of (regular) cars, taxis,
and eighteen-wheelers. The
input string will consist of c's, t's, 8's, and dashes, where the
-8--c--c-t-cmeans there is a line consisting of an eighteen-wheeler, two cars, a taxi, and one more car. The rules for movement are as follows:
-8---c-c--t-You are to complete a program that counts the number of steps needed to clear the line of vehicles (that is, to effectively make it into all dashes). A portion of the code is being given to you, you will write the remaining portions.
Please do write your own code for this assignment, but you can freely consult with other students. We will not be running plagiarism checks on this assignment.
main.cpp
: main program: you
should not change this (esubmit will use its own version)
road.h
: initial version of classes
for recording the state of road and vehicles
road.cpp
: initial version of classes
for recording the state of road and vehicles
road
files and submit
your code on esubmit. You are done when all tests pass. Do not
introduce additional includes, and do not worry about writing destructors.
Vehicle
must be abstract. Remember you make a
method abstract in C++ by using = 0
, and such methods must
be virtual. The result will be that class Vehicle
is abstract.
road.h
and road.cpp
to esubmit using the assignment ex7honk. Do not
submit main.cpp. There is nothing to submit to Canvas. The code will be
graded for correctness, not style, so there are no documentation
requirements.