Question: java In project car, write a Car class that has the following attributes: a make and model name (such as Honda Fit or Ford F--150

java

In project car, write a Car class that has the following attributes: a make and model name (such as Honda Fit or Ford F--150 or Toyota Prius), an odometer value, an amount of gasoline, a gas tank capacity, and a miles-per-gallon rating. The gas tank capacity and the miles-per-gallon should be unchangeable after the car has been created (declared with the keyword 'final'). Your car class should also declare the following methods: a constructor, a toString method that returns a String describing the car, a drive method that drives the car a given number of miles, and a fillTheTank method that refills the gasoline. To test this car you should create a TestCar class with a main in it. Your main method should create a few cars, drive them around and refill the gas a few times, printing out the cars after each action.

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!