Question: PLEASE READ AND DO IT CORRECTLY, I WILL UPVOTE YOUR ANSWER AS WELL. IT HAS 3 PARTS: VEHICLE, DRIVER, AND THE EXTRA CREDIT. THANK YOU

PLEASE READ AND DO IT CORRECTLY, I WILL UPVOTE YOUR ANSWER AS WELL. IT HAS 3 PARTS: VEHICLE, DRIVER, AND THE EXTRA CREDIT. THANK YOU

PLEASE READ AND DO IT CORRECTLY, I WILL UPVOTE YOUR ANSWER AS

Write a class called Vehicle containing the following fields: make: (.e. Ford) model: (i.e. Taurus) year speed distance (Distance traveled in race) It should include a constructor that takes make, model, and year and initializes the proper fields with this data. Zero out the speed and distance. The methods a Vehicle should have are: accelerate() - which increases the speed by 10 mph. Every time a user runs accelerate() on an instance of Vehicle, the speed increases by 10. Since no stock car can realistically go an unlimited speed, cap the speed to 120 mph. brake() - decreases the speed by 10 mph. Every time a user runs brakes() on an instance of Vehicle, the speed decreases by 10. Since slowest you can go is O mph, make sure you prevent negative speeds. (There's no going backwards.) adjustCarSpeed() - Use a random number generator to determine whether a car accelerates or brakes. 50% of the time a car will accelerate; 25% of the time a car will stay the same speed, the other 25% the car will brake. accessor (getters) - methods that return the values of these private fields. setDistance() - that takes a time in minutes, calculates the distance traveled by the car based on the current speed and time input and adds it to the total distance traveled by the car. .toStringo - So you can print the object properly If written correctly, your Vehicle class should work plug and play into both driver projects! Submit a gist of the Vehicle class as well as the drivers. Make sure you include the proper global header. Look at the Project Template for that header. Driver Description Both drivers run a two car 500 mile race. First car to reach 500 miles wins. The Vehicles run in a loop. Each loop will represent 1 minute. If a car is going 50mph, then in one minute the distance traveled by the car is 50.0 / 60.0 miles. The loop will generate a random value, decide whether to accelerate, brake, or do nothing to the cars. You can then query the car's speed to determine the distance traveled in that minute. Accumulate their distances. The loop will terminate as soon as the distance traveled by a car exceeds 500 miles. Sample loop: private static void race ThemCars(Vehicle car1, Vehicle car2) { while (car1.getDistance()

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!