Answered step by step
Verified Expert Solution
Link Copied!

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 image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions