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 vehicles to creep forward a bit at a time until each has left the parking 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 c means there is a car in that spot, a t means there is a taxi, and an 8 means there is an eighteen-wheeler. There are no spaces in the input. For example,
-8--c--c-t-c
means there is a line consisting of an eighteen-wheeler, two cars, a taxi, and one more car. The rules for movement are as follows:
The vehicles are moving left to right, so in the first step the car leaves the parking lot. It honks at that point to celebrate. Because a taxi driver is aggressive, it moves forward one space. The next car stays where it is, and the third car moves forward one step. The eighteen-wheeler also stays in place. Thus the next step of the line is
-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 vehiclesroad.cpp: initial version of classes for recording the
state of road and vehiclesYou will complete the TODOs in the two 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.