Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

Create an Automobile class for a dealership

Computer Science Jan 26, 2021

Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year, vin number, miles per gallon, and speed.

Include get and set methods for each field.

Do not allow the ID to be negative or more than 9999; if it is, set the ID to 0.

Do not allow the year to be earlier than 2000 or later than 2017; if it is, set the year to 0.

Do not allow the miles per gallon to be less than 10 or more than 60; if it is, set the miles per gallon to 0.

Car speed should be initialized as 0.

Include a constructor that accepts arguments for each field value and uses the set methods to assign the values.

Also write two methods, Accelerate () and Brake ().

Whenever Accelerate () is called, increase the speed by 5, and whenever Brake () is called, decrease the speed by 5.

To allow users to specify the speed to increase (or decrease), create two overloading methods for Accelerate () and Brake () that accept a single parameter specifying the increasing (or decreasing) speed.

Write an application that declares several Automobile objects and demonstrates that all the methods work correctly.

 

Expert Solution

For detailed step-by-step solution, place custom order now.
Need this Answer?

This solution is not in the archive yet. Hire an expert to solve it for you.

Get a Quote
Secure Payment