Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java please, Without using throws Write a class called Vehicle containing the following fields: - make: (i.e. Ford) - model: (i.e. Taurus) - year
In Java please, Without using throws
Write a class called Vehicle containing the following fields: - make: (i.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: - accessor (getters) - methods that return the values of these private fields. (setDistance is a bit different.) - mutators (setters) - methods that change the values of these private fields. Make sure bad data does not enter the object. - make should not be empty or null - model should not be empty or null - year >=1950 - speed >=0 - setDistance is special and is described next - 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. - toString() - 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 Sample loop: private static void raceThemCars(Vehicle car1, Vehicle car2) \{ while (car1.getDistance ()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