Question
pls use java as easy as possible P1: Enumerated Types as Separate Files Create an enum of CarType holding names of different types of cars.
pls use java as easy as possible
P1: Enumerated Types as Separate Files
Create an enum of CarType holding names of different types of cars. Save the file with the same name as CarType.java (include only the enum declaration, do NOT include a class header).
Create another enum of CarColor holding colors for cars. Save the file with the same name as CarColor.java (include only the enum declaration, do NOT include a class header).
Write a class SportsCar that has following three private fields: make a CarType variable, color a CarColor variable and price a double variable.
The class should have following methods.
- a constructor with three arguments that sets the values for make, color and price
- getMake method: returns the make of car
- getColor method: return the color of car
- getPrice method: returns the price of the car
- toString method
Write a demo program to test the class.
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