Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CarType enum Create an enumeration named CarType to represent the types of cars as follows: SUV Hatchback Sedan Truck Car Class This class consists

imageimageimage

CarType enum Create an enumeration named CarType to represent the types of cars as follows: SUV Hatchback Sedan Truck Car Class This class consists of the following members. All the properties have public getters and no setters. manufacturer : string o A string property to store manufacturer name such as "Honda" make : int o An int property to store the making year of car such as 2018 model : string o A string property to store the model's name of the case such as "Civic" VI_NUMBER : int = 1001 o This is a static field to create unique Vehicle Identification Number for each car object. This number should be automatically incremented by 100 each time the constructor of this class is called. This field will be used to initialize the VIN field. VIN: int o This field represents unique Vehicle Identification Number for each car object which will be initialized from VI_NUMBER field. basePrice : double o This property stores the base price of the car such as $35000.00 type : carType o This property stores type of the car such as Sedan. It must receive value of the CarType enumeration. Define the following constructors for this class: Car (string manufacturer, int make, string model, double basePrice, CarType type) o This constructor will assign received parameters to the respective class properties o It should also increment VIN by 10 Implement the following methods in the class: override string toString() o this method should display all the car details in appropriate format. Dealership class This class consists of the following members. All the properties have public getters and no setters. carList : ArrayList o This is a static property that holds a list of car objects that dealership has in stock. id: string o A string property to store ID of each dealership such as "D22_101" name: string o A string property to store name of the dealership such as "The Six Dealership" address: string o A string property to store the address of dealership such as "1029 Main Street, Toronto" Define the following constructors for this class: Dealership (string ID, string name, string address) o This constructor will assign received parameters to the respective class properties Implement the following methods in the class: void addCar(string manufacturer, int make, string model, double basePrice, CarType type) o this method will create a car object using provided parameters and add the car object in the carlist array. void showCars(String manufacturer) o this method will display all the cars for which the manufacturer is same as the given parameter. o For example, showCars("Toyota") will show all the cars from carList property that has Toyota as manufacturer. void showCars(string manufacturer, int make) o this method will display all the cars for which the manufacturer and make is same as the given parameters. o For example, showCars("Toyota", 2018) will show all the cars from carlist property that has Toyota as manufacturer and make in 2018. void showCars(string manufacturer, int make, double base Price) o this method will display all the cars for which the manufacturer and make is same as the given parameters as well as basePrice which is NOT more than given parameter value. o For example, showCars("Toyota", 2018, 10000) will show all the cars from carList property that has Toyota as manufacturer, make in 2018 and basePrice not more than 10000. override string toString() o this method should display all the dealership details in appropriate format. Test Class To test the above-mentioned classes, create a class named CarTest.java. This class will contain the main() method that should perform the following operations: o Create at least 2 carDealership objects o For each of the objects, create and add at least 3 car objects in the array, call the showCars() method with different parameters and/or values to demonstrate method overloading.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Below is the implementation of the CarType enum Car class and Dealership class based on the provided ... 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

An Introduction to Management Science Quantitative Approach to Decision Making

Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams, Jeffrey D. Camm, James J. Cochran

15th edition

978-1337406529

More Books

Students also viewed these Programming questions

Question

understand the limitations of classic models of job design.

Answered: 1 week ago