er gallon (mpg). 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 2005 or later than 2024; if it is, set the year to 0. Do not allow the miles per gallon to be less than 1
er gallon (mpg). 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 2005 or later than 2024; if it is, set the year to 0. Do not allow the miles per gallon to be less than 1
er gallon (mpg). 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 2005 or later than 2024; if it is, set the year to 0. Do not allow the miles per gallon to be less than 1
Create an Automobile class for a dealership. Include fields for an ID number (id), make (make), model (model), color (color), year (year), and miles per gallon (mpg).
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 2005 or later than 2024; 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.
Include a default constructor that accepts no arguments and an overloaded constructor that accepts arguments for each field value and uses the set methods to assign the values.
Part B
Write an application called TestAutomobiles that declares two Automobile objects. Write a function called enterData() that prompts the user for the data values for an Automobile object and returns that object. When you test the program, be sure to enter some invalid data to demonstrate that all the methods work correctly.
An example of the program is shown below:
Enter ID (an integer) >> 12
Enter make >> Mercury
Enter model >> Monterey
Enter color >> Dark Blue
Enter year (4 digits) >> 2007
Enter mpg >> 17
Enter ID (an integer) >> 599
Enter make >> Pontiac
Enter model >> G5
Enter color >> White
Enter year (4 digits) >> 2006
Enter mpg >> 25
ID#12 Mercury Monterey Dark Blue 2007 17.0 miles per gallonID#599 Pontiac G5 White 2006 25.0 miles per gallon
Task 01: Create the Automobile class.
Task 02: Add data fields to the Automobile class.
Task 03: Define the get and set methods for the id data field.
Task 04: Define the get and set methods for the make data field.
Task 05: Define the get and set methods for the model data field.
Task 06: Define the get and set methods for the color data field.
Task 07: Define the get and set methods for the year data field.
Task 08: Define the get and set methods for the mpg data field.
Task 09: Create a default constructor and an overloaded constructor for the Automobile class.
Task 10: Create the TestAutomobiles class.
Task 11: Implement the enterData() function.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.