Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started