Question: Task 1 ) Define a FuelType enum with values for different fuel types such as Gasoline, Diesel, Electric. b ) mplement the classes below with

Task 1)
Define a FuelType enum with values for different fuel types such as "Gasoline", "Diesel", "Electric".
b) mplement the classes below with the following instructions:
equals() compares two objects based on the field values: If they match, it returns true; if not, false
toString() prints out the fields of the class.
Make sure methods use/return a deep copy of the Engine object (not a reference copCar
-make: String -model: String -year: int
-engine : Engine
+Car(ma:String, mo:String, y:int, eng:Engine)
+setMake(ma:String) : void +setModel(mo:String) : void
+setYear(y:int): void +setEngine(eng:Engine): void
+getMake(): String +getModel(): String +getYear() : int +getEngine(): Engine +toString(): String
+equals(car2: Car): boolean
Engine
-EngineType: String
-Horsepower: int -fuelType: FuelType
+Engine(et:String, hp:int, ft:FuelType)+Engine(engine2: Engine)+setEngineType(et:String) : void +setHorse Power(hp:int) : void +setFuelType(ft:FuelType) : void +getEngineType(): String +getHorsePower() : int +getFuelType(): FuelType
+toString(): String
+equals(eng2: Engine): boolean)
 Task 1) Define a FuelType enum with values for different fuel

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!