From f90497c9ad8b9928957ad4dfae7b89f55a2760bd Mon Sep 17 00:00:00 2001 From: 2120940 <2120940@stud.hs-mannheim.de> Date: Sun, 8 Jan 2023 10:46:03 +0100 Subject: [PATCH] =?UTF-8?q?weitere=20Funktionalit=C3=A4ten=20(vorerst=20al?= =?UTF-8?q?le)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tpe/exceptions/roboter/RobotFactory.java | 57 ++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) 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); + } }