Robot

Report a typo

The given classes are components of the Factory Method pattern.

Robot is the product and RobotCleaner is the concrete product.

Implement the factory method in RobotFactory methods to create RobotCleaner.

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

Sample Input 1:

RAS012

Sample Output 1:

cleaner-robot: {
	name : RAS012
	description : Robot will clean my room and dry my socks
	power : 100
}
Write a program in Java 17
import java.util.Scanner;

/** Product */
abstract class Robot {

public abstract String getName();

public abstract String getDescription();

public abstract int getPower();

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

/** Type of product - Robot Type */
enum RobotType {
ROBOT_CLEANER
}

/** Concrete Product - Robot Cleaner */
class RobotCleaner extends Robot {

private String name;
private String description;
private int power;

public RobotCleaner(String name, String description, int power) {
this.name = name;
this.description = description;
this.power = power;
___

Create a free account to access the full topic