diff --git a/Robbie-Management-System/src/domain/Nexus6.java b/Robbie-Management-System/src/domain/Nexus6.java new file mode 100644 index 0000000..dcef6bf --- /dev/null +++ b/Robbie-Management-System/src/domain/Nexus6.java @@ -0,0 +1,39 @@ +package domain; + +import exceptions.RobotException; +import exceptions.RobotIllegalStateException; +import roboterSystem.Robot; + +public class Nexus6 extends Robotermodell implements Robot { + private static final Nexus6 NEXUS6 = new Nexus6(); + + private Nexus6() { + setName("Pris"); + setiD(19281982); + power = false; + } + + public static Nexus6 getInstance() { + return NEXUS6; + } + + @Override + public void triggerPowerSwitch() { + //bleibt ausgeschaltet + } + + @Override + public int[] think(int[] zahlen) throws RobotException { + try { + if (this.isPowerOn() == false) { + throw new RobotIllegalStateException(); + } + } catch (RobotIllegalStateException rise) { + letzteException = rise; + rise.printStackTrace(); + } + + return null; + } + +} diff --git a/Robbie-Management-System/src/domain/RobotType.java b/Robbie-Management-System/src/domain/RobotType.java index a7df994..73c2fca 100644 --- a/Robbie-Management-System/src/domain/RobotType.java +++ b/Robbie-Management-System/src/domain/RobotType.java @@ -1,5 +1,5 @@ package domain; public enum RobotType { - C3PO, R2D2; + C3PO, R2D2, NEXUS6; } diff --git a/Robbie-Management-System/src/domain/Robotermodell.java b/Robbie-Management-System/src/domain/Robotermodell.java index 704e661..6e96d3a 100644 --- a/Robbie-Management-System/src/domain/Robotermodell.java +++ b/Robbie-Management-System/src/domain/Robotermodell.java @@ -10,7 +10,7 @@ import roboterSystem.Robot; public abstract class Robotermodell implements Robot { private int iD; private String name; - private boolean power = true; + protected boolean power = true; protected RobotException letzteException; public void setName(String name) { @@ -69,8 +69,11 @@ public abstract class Robotermodell implements Robot { if (this instanceof C3PO) { hilfszeichen = ";"; - } else { + } else if (this instanceof R2D2){ hilfszeichen = ","; + } else { + //wird beim Nexus6 geworfen + throw new RobotIllegalStateException(); } Arrays.stream(zahlen)