diff --git a/Roboter/tpe/exceptions/roboter/RobotFactory.java b/Roboter/tpe/exceptions/roboter/RobotFactory.java index 054e6ea..230e960 100644 --- a/Roboter/tpe/exceptions/roboter/RobotFactory.java +++ b/Roboter/tpe/exceptions/roboter/RobotFactory.java @@ -2,11 +2,18 @@ package tpe.exceptions.roboter; import java.util.HashMap; +import tpe.exceptions.RobotException; + public class RobotFactory { - private Nexus6 nexus6=Nexus6.getInstance(); - + private Robots nexus6=Nexus6.getInstance(); + private String factoryName; private HashMap robotStock=new HashMap<>(); + public RobotFactory(String factoryName) { + this.factoryName=factoryName; + robotStock.put(nexus6.getId(), nexus6); + } + public int constructRobot(RobotType robotType, String name) { Robots robot; if(RobotType.R2D2==robotType) { @@ -38,4 +45,50 @@ public class RobotFactory { } 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); + } }