Ex 7: Clearing the road with inheritance

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 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 agressive, 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.

Provided Code

You 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.

Constraints

Submission