Question: JAVA HELP VEHICLE PROGRAM AND UML DIAGRAM Problem Description: Implement the classes and interface described in the following problem description a) Implement the UML Class
JAVA HELP VEHICLE PROGRAM AND UML DIAGRAM

Problem Description: Implement the classes and interface described in the following problem description a) Implement the UML Class Diagram below. The line with the diamond at the end defines aggregation, that is a Car holds an instance variable of type Engine. The lines with the black triangle at the end mean that each class implements the interface Engine. Create an interface called Engine with the methods: getHorsepower(), turnOn(), and turnOff(). Create three classes called SportEngine, DieselEngine, and ElectricEngine that implement the Engine interface. All classes should have an instance variable to keep track of the engine's state which is set by the turnOn() and turnOff() methods. Each class has a final instance variable horsepower that gets initialized by a constructor parameter. Each class also implements the toString() method that prints the engine type and horsepower and an equals(Object obj) method to compare an engine object to another object. Finally, create a class called Car. The Car class should implement the toString() method which returns a String with the make, model, and engine. > make: String Engine - model: String - year: int speed: int + turnOn(): void +turnOff): void +getHorsePower(): int +drive(speed: int): void +stop): void +isStopped: boolean +setEngine(engine: Engine): void +getEngine(): Engine SportEngine DieselEngine ElectricEngine - isEngineOn:booleanisEngineOn: boolean - isElectricMotorOn: boolean horsepower: int - horsepower: int horsepower: int b) Create a class CarProgram with a main method. Create a class variable (static) of type Scanner. In the main method create an object of the Car class. Prompt the user to enter a make, then prompt the user to enter a model, then prompt the user to enter a year, set the speed to 0. Afterwards, the program should repeatedly ask the user to enter an option: d = drive, e - select engine, q to quit. Use the scanner method .next().charAt(O) to get the char from the input. You may use a switch statement to check the input. a. If 'd' is entered, prompt the user to enter a speed (int). Read the speed from the 1. 2. 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
