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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!