Question: 5. [20 marks] (TestCar.java) Design a class named Car. The Car class has the following private data fields: year built model, make, speed, traveling time,

 5. [20 marks] (TestCar.java) Design a class named Car. The Car

5. [20 marks] (TestCar.java) Design a class named Car. The Car class has the following private data fields: year built model, make, speed, traveling time, and total kilometers covered Create a constructor with a year, a model and a make. Create all the necessary accessors and mutators for the data fields. Add a method for calculating the total kilometers covered. Create a method for starting the car (Set the initial speed to 40km/hour), a method for moving the car for a number of minutes, and a method for stopping the car. In the main method, create a car, start it, and move it for 30 minutes. Next, change the speed to 60km/hour and move it for 60 minute. Then, change the speed to 30km/hour and move it for 20 minutes. At the end, stop the car, and display the car's year built, model, make, and the total kilometers covered. For the sample values given above, the total kilometers covered should be 90

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!