Challenge for Inheritance

Challenge

The Class Car appears below. Fill in the constructor and accelerate method of the Class RocketCar:

  • constructor - It should call Car's constructor, and also set rocketFuel to 10.
  • accelerate - It should call Car's accelerate method (to run the regular engine), but it should also fire its rocket engine. This means if (and only if) it has rocket fuel left, it should increase the speed by another 2 units and decrease the rocketFuel by 1 unit.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Contact Us
Sign in or email us at [email protected]