weitere Funktionalitäten (vorerst alle)

main
Lukas Berens 2023-01-08 10:46:03 +01:00
parent 3d43125f32
commit f90497c9ad
1 changed files with 55 additions and 2 deletions

View File

@ -2,11 +2,18 @@ package tpe.exceptions.roboter;
import java.util.HashMap; import java.util.HashMap;
public class RobotFactory { import tpe.exceptions.RobotException;
private Nexus6 nexus6=Nexus6.getInstance();
public class RobotFactory {
private Robots nexus6=Nexus6.getInstance();
private String factoryName;
private HashMap<Integer,Robots> robotStock=new HashMap<>(); private HashMap<Integer,Robots> robotStock=new HashMap<>();
public RobotFactory(String factoryName) {
this.factoryName=factoryName;
robotStock.put(nexus6.getId(), nexus6);
}
public int constructRobot(RobotType robotType, String name) { public int constructRobot(RobotType robotType, String name) {
Robots robot; Robots robot;
if(RobotType.R2D2==robotType) { if(RobotType.R2D2==robotType) {
@ -38,4 +45,50 @@ public class RobotFactory {
} }
return randomID; return randomID;
} }
public String getFactoryName() {
return factoryName;
}
public Robots getRobot(int id) {
return robotStock.get(id);
}
public boolean triggerPower(int id) {
Robots robot=getRobot(id);
robot.triggerPowerSwitch();
return robot.powerStatus;
}
public boolean powerStatus(int id) {
Robots robot=getRobot(id);
return robot.powerStatus;
}
public String robotInfo(int id) {
Robots robot=getRobot(id);
return robot.toString();
}
public Robots dismantleRobot(int id) {
return robotStock.remove(id);
}
public RobotException robotBlackbox(int id) {
Robots robot=getRobot(id);
return robot.getLastException();
}
public String robotInstructions(int id, int[]zahlen) throws RobotException {
Robots robot=getRobot(id);
return robot.speak(robot.think(zahlen));
}
public int robotStockSize() {
return robotStock.size();
}
public boolean containsRobot(int id) {
return robotStock.containsKey(id);
}
} }