Motors

Report a typo

You have an excellent idea: you decide to automate the production of motors.

You have 4 types of motors: electric, hydraulic, pneumatic and warp drive.

You must implement MotorFactory and the specified classes of motors.

Please, do not change the provided code of the motor classes.

Sample Input 1:

E
R-45
1000

Sample Output 1:

Electric motor={model:R-45,power:1000}
Write a program in Java 17
import java.util.Scanner;

/* Product - Motor */
abstract class Motor {

String model;
long power;

public Motor(String model, long power) {
this.model = model;
this.power = power;
}

@Override
public String toString() {
return "motor={model:" + model + ",power:" + power + "}";
}
}

class PneumaticMotor extends Motor {
// write your code here ...
}

class HydraulicMotor extends Motor {
// write your code here ...
}

class ElectricMotor extends Motor {
// write your code here ...
}

class WarpDrive extends Motor {
// write your code here ...
}

class MotorFactory {
___

Create a free account to access the full topic