Question: nhance your understanding of inheritance in object - oriented programming by extending a Car class to create an Electric Car ( EV ) class. This

nhance your understanding of inheritance in object-oriented programming by extending a Car class to create an Electric Car (EV) class. This new class will include additional properties and methods specific to electric vehicles.
Tasks:
Implement EV Class:
Extend the Car class to create an EV class that also includes a charge property representing the current battery charge in percentage.
Commit: "Create EV class extending Car with additional charge property."
Charge Battery Method:
Implement a chargeBattery method in the EV class that takes an argument chargeTo and sets the battery charge to this value.
Commit: "Implement chargeBattery method in EV class."
Customize Accelerate Method:
Override the accelerate method in the EV class to increase the car's speed by 20 km/h and decrease the battery charge by 1%. Log the new speed and charge level in the console with a message like: "Tesla going at 140 km/h, with a charge of 22%".
Commit: "Override accelerate method in EV class to adjust speed and charge."
Testing EV Class:
Create an EV object using the provided test data and experiment with calling the accelerate, brake, and chargeBattery methods.
Observe and document the behavior of the EV object, particularly how the battery charge impacts the ability to accelerate.
Commit: "Test EV class methods with different operations."
Test Data:
Car 1: A 'Tesla' starting at 120 km/h, with a battery charge of 23%.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!