When working with C++, overload the
<<
operator instead of using a
toString()
method.
The
accelerate()
and
decelerate()
methods should be used to change the speed.
However, they are subject to the constraints that the
speed is always greater than or equal to zero and less than or equal to maxSpeed
.
Attempts to increase speed above
maxSpeed
or decrease it below 0 should simply pin the speed to the boundaries.
Note that this class is quite general and can actually describe pedestrians as well.
In the text area below, type or paste your answer.
Click the Submit button to submit the factory method exercise.