Robot factory

Report a typo

Let's expand our RobotFactory! We've added a new Robot type — the Guardian.

Provide the RobotGuardian class and implement a factory method in RobotFactory methods to create Robot instances.

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

Sample Input 1:

TYU11
O13L3

Sample Output 1:

cleaner-robot: {
	name : TYU11
	description : Robot will clean my room and dry my socks
	power : 100
}
guardian-robot: {
	name : O13L3
	description : Knight will guard my daughter while she is sleeping
	power : 200
}
Write a program in Java 17
import java.util.Scanner;

/** Product - Robot */
abstract class Robot {
private int power;

Robot(int power) {
this.power = power;
}

public abstract String getName();

public abstract String getDescription();

public int getPower() {
return power;
}

@Override
public String toString() {
return "robot: {\n\t" +
"name : " + getName() + "\n\t" +
"description : " + getDescription() + "\n\t" +
"power : " + getPower() + "\n}";
}
}

/** Robot types */
enum RobotType {
ROBOT_CLEANER,
/** write your code here ... */
}

/** Concrete Product - Robot Cleaner */
class RobotCleaner extends Robot {
private String name;
___

Create a free account to access the full topic