Hi all,
I was hoping that someone may have some insight for me on the following question.
Write a class that represents a car object. A Car has the following data fields:
• yearModel – The model year of the car
• make – The manufacturer of the car
• speed – The speed the car is currently travelling
A Car should have the following as well:
• A Constructor that takes as arguments the car’s year and make. The speed of the care should be set to 0.
• Accessors – there should be an appropriate accessor method for each of the data fields.
• Mutators – there should be an accelerate method and a brake method. Each of these methods adds or subtracts 5
from the speed of the car respectively. Note: The speed of the car should never be less than 0 and never more than
210 (assume km/h). Your methods should make sure these limits are respected.
• ***Write JavaDoc comments for this class.***
Write a tester class that:
• Prompts the user for the make and model of the Car
• Constructs a Car with the input given
• Accelerate once and show the speed of the Car
• Use a loop to accelerate 5 (or better yet a random number of) times and show the speed of the Car.
• Use a loop to decelerate until the Car is stopped. Display the number of times the brakes were applied.
The following output is what is expected.
Please enter the make and model of the car: Tiberon 2006
New car created! Tiberon, 2006
The current speed is 5.
The current speed is 30.
The current speed is 0, and the brakes were applied 6 times.
The work that I have done so far is as follows:
class code:
Code tester:
The output after it runs is as follows:
Please enter the make and model of the car: Tiberon 2006
New car created! Tiberon, 2006
The current speed is 5
The current speed is 10
The current speed is 15
The current speed is 20
The current speed is 25
The current speed is 20
The current speed is 15
The current speed is 10
The current speed is 5
The current speed is 0
The current speed is 0, and the brakes were applied 6 times.
The question I have is how do I get rid of the line that is bolded in the output, the "The current speed is 0" line.
If anyone has a simple quick fix as soon as possible it would be greatly appreciated, as this is due in less than 3 hrs from now...lol..