In this exercise, you will develop concrete subclasses for the Vehicle class, the
Bus
,
Car
,
Pedestrian
, and
Bicycle
. These are the parameters for the four classes:
- The
Car
class should be 6.0 meters long and have a maximum speed of 120 kilometers per hour.
- The
Bus
class should be 18 meters long with a maximum speed of 92 kilometers per hour.
- The
Bicycle
class should be 1.5 meters long with a maximum speed of 25 kilometers per hour.
- The
Pedestrian
class should have a length of 0 (pedestrians tend to bunch up side by side at intersections rather than queue in line) and a maximum speed of 4 kilometers per hour.
For all of these, all you need to do is define the appropriate class with the necessary constructor that sets the values as specified. A more complex simulation might also add additional behavior to these subclasses,
but we will not need that for our simple project.
In the text area below, type or paste your solution and click the Submit button.