diff --git a/Roboter/tpe/exceptions/roboter/C3PO.java b/Roboter/tpe/exceptions/roboter/C3PO.java index 90bb634..216b6c8 100644 --- a/Roboter/tpe/exceptions/roboter/C3PO.java +++ b/Roboter/tpe/exceptions/roboter/C3PO.java @@ -25,20 +25,7 @@ public class C3PO extends Robots{ } - @Override - public String speak(int[] zahlen) throws RobotException { - - for (int i = 0; i < zahlen.length; i++) { - sb.append(zahlen[i]); - if (i < zahlen.length - 1) { - sb.append("; "); - } - } - - String output = sb.toString(); - return output; - - } + @Override public int[] think(int[] zahlen) throws RobotIllegalStateException, RobotMagicValueException { diff --git a/Roboter/tpe/exceptions/roboter/R2D2.java b/Roboter/tpe/exceptions/roboter/R2D2.java index 9eaec30..9d718a6 100644 --- a/Roboter/tpe/exceptions/roboter/R2D2.java +++ b/Roboter/tpe/exceptions/roboter/R2D2.java @@ -25,20 +25,7 @@ public class R2D2 extends Robots { return id; } - @Override - public String speak(int[] zahlen) throws RobotException { - - for (int i = 0; i < zahlen.length; i++) { - sb.append(zahlen[i]); - if (i < zahlen.length - 1) { - sb.append(", "); - } - } - String output = sb.toString(); - return output; - - } @Override diff --git a/Roboter/tpe/exceptions/roboter/Robots.java b/Roboter/tpe/exceptions/roboter/Robots.java index 61e03e5..da8cf9c 100644 --- a/Roboter/tpe/exceptions/roboter/Robots.java +++ b/Roboter/tpe/exceptions/roboter/Robots.java @@ -1,5 +1,8 @@ package tpe.exceptions.roboter; +import java.util.Arrays; +import java.util.stream.Collectors; + import tpe.exceptions.RobotException; import tpe.exceptions.RobotIllegalStateException; import tpe.exceptions.RobotMagicValueException; @@ -48,6 +51,7 @@ public abstract class Robots implements Robot{ } public String speak(int[] zahlen) throws RobotException { + if(powerStatus==false) { throw new RobotIllegalStateException("Der Roboter ist ausgeschaltet!", this.getName()); @@ -55,9 +59,21 @@ public abstract class Robots implements Robot{ else if(checkRobotMagicValueException(zahlen)==true) { throw new RobotMagicValueException("Zahl 42 kann nicht verarbeitet werden!",this.getName()); + }else + if(zahlen[0]