diff --git a/Roboterfabrik/src/Domäne/Nexus6.java b/Roboterfabrik/src/Domäne/Nexus6.java index 79020f1..35b8aad 100644 --- a/Roboterfabrik/src/Domäne/Nexus6.java +++ b/Roboterfabrik/src/Domäne/Nexus6.java @@ -1,13 +1,13 @@ package Domäne; -import Exception.RobotException; -import Exception.RobotIllegalStateException; +import tpe.exceptions.roboter.exceptions.RobotException; +import tpe.exceptions.roboter.exceptions.RobotIllegalStateException; public class Nexus6 extends Roboter { String name; int id; - private static Nexus6 pris; + private static Nexus6 PRIS; private Nexus6() { @@ -17,13 +17,14 @@ public class Nexus6 extends Roboter { } - + public static Nexus6 getInstance () { - if (pris == null) { - pris = new Nexus6(); + if (PRIS == null) { + PRIS = new Nexus6(); + } - return pris; + return PRIS; } @Override @@ -36,12 +37,19 @@ public class Nexus6 extends Roboter { public int getId() { return id; } - + //Methode soll Fehler ausgeben, da der Roboter nicht Funktioniert. @Override - public int[] think(int[] zahlen)throws RobotException { + public String speak(int[] zahlen) throws RobotException { + throw new RobotIllegalStateException ("Roboter ausgeschaltet und Defekt!"); + + } + + //Methode soll Fehler ausgeben, da der Roboter nicht Funktioniert. + @Override + public int[] think(int[] zahlen) throws RobotException { + throw new RobotIllegalStateException ("Roboter ausgeschaltet und Defekt!"); - return null; } } diff --git a/Roboterfabrik/src/Domäne/RobotFactory.java b/Roboterfabrik/src/Domäne/RobotFactory.java index 5129745..ace98bc 100644 --- a/Roboterfabrik/src/Domäne/RobotFactory.java +++ b/Roboterfabrik/src/Domäne/RobotFactory.java @@ -10,16 +10,16 @@ public RobotFactory (String name) { this.name = name; } - public int addRobot (RobotType robotType) { + public int addRobot (RobotType robotType, String name) { Roboter roboter; if (RobotType.R2D2 == robotType) { - roboter = new R2D2 ("R2D2"); + roboter = new R2D2 (name); roboters.put(roboter.getId(), roboter); return roboter.getId(); } else if (RobotType.C3PO == robotType) { - roboter = new C3PO ("C3PO"); + roboter = new C3PO (name); roboters.put(roboter.getId(), roboter); return roboter.getId(); diff --git a/Roboterfabrik/src/Domäne/Roboter.java b/Roboterfabrik/src/Domäne/Roboter.java index a04a3f4..75ac1b4 100644 --- a/Roboterfabrik/src/Domäne/Roboter.java +++ b/Roboterfabrik/src/Domäne/Roboter.java @@ -3,7 +3,7 @@ package Domäne; import java.util.stream.Stream; import tpe.exceptions.roboter.Robot; -import tpe.exceptions.roboter.RobotException; +import tpe.exceptions.roboter.exceptions.RobotException; public abstract class Roboter implements Robot { @@ -66,6 +66,7 @@ public abstract class Roboter implements Robot { Stream.of(zahlen).forEach(n -> ausgabe = ausgabe + n + ";"); return ausgabe; } + return null; } diff --git a/Roboterfabrik/src/tpe/exceptions/roboter/RobotControl.java b/Roboterfabrik/src/tpe/exceptions/roboter/RobotControl.java index 814f272..6a6304b 100644 --- a/Roboterfabrik/src/tpe/exceptions/roboter/RobotControl.java +++ b/Roboterfabrik/src/tpe/exceptions/roboter/RobotControl.java @@ -1,6 +1,8 @@ package tpe.exceptions.roboter; import tpe.exceptions.roboter.exceptions.RobotException; +import tpe.exceptions.roboter.exceptions.RobotIllegalStateException; +import tpe.exceptions.roboter.exceptions.RobotMagicValueException; /** * Das Interface repräsentiert einen einfachen Roboter mit seinen Funktionen. diff --git a/Roboterfabrik/src/tpe/exceptions/roboter/exceptions/RobotException.java b/Roboterfabrik/src/tpe/exceptions/roboter/exceptions/RobotException.java new file mode 100644 index 0000000..aa6d2cd --- /dev/null +++ b/Roboterfabrik/src/tpe/exceptions/roboter/exceptions/RobotException.java @@ -0,0 +1,8 @@ +package tpe.exceptions.roboter.exceptions; + +public class RobotException extends Exception { + + public RobotException (String message) { + super(message); + } +} diff --git a/Roboterfabrik/src/tpe/exceptions/roboter/exceptions/RobotIllegalStateException.java b/Roboterfabrik/src/tpe/exceptions/roboter/exceptions/RobotIllegalStateException.java new file mode 100644 index 0000000..46928da --- /dev/null +++ b/Roboterfabrik/src/tpe/exceptions/roboter/exceptions/RobotIllegalStateException.java @@ -0,0 +1,8 @@ +package tpe.exceptions.roboter.exceptions; + +public class RobotIllegalStateException extends RobotException { + + public RobotIllegalStateException (String message) { + super(message); + } +}