diff --git a/Roboterfabrik/src/Domäne/C3PO.java b/Roboterfabrik/src/Domäne/C3PO.java index 428639d..4151fb6 100644 --- a/Roboterfabrik/src/Domäne/C3PO.java +++ b/Roboterfabrik/src/Domäne/C3PO.java @@ -9,7 +9,7 @@ public class C3PO extends Roboter { private int id; //static int idZähler = 10000; private RobotType robotType; - RobotException fehler; + //RobotException fehler; public C3PO(String name, int id) { super(name); @@ -51,6 +51,9 @@ public class C3PO extends Roboter { throw fehler; } + public RobotType getRobotType () { + return this.robotType; + } } diff --git a/Roboterfabrik/src/Domäne/Nexus6.java b/Roboterfabrik/src/Domäne/Nexus6.java index 406a78d..b1cfb13 100644 --- a/Roboterfabrik/src/Domäne/Nexus6.java +++ b/Roboterfabrik/src/Domäne/Nexus6.java @@ -5,15 +5,17 @@ import tpe.exceptions.roboter.exceptions.RobotIllegalStateException; public class Nexus6 extends Roboter { - String name; - int id; - RobotException fehler; + private String name; + private int id; + //RobotException fehler; private static Nexus6 PRIS; + private RobotType robotType; private Nexus6() { super("Pris"); this.id = 19_281_982; + robotType = RobotType.NEXUS6; } @@ -55,4 +57,12 @@ public class Nexus6 extends Roboter { } + + + @Override + public RobotType getRobotType() { + + return this.robotType; + } + } diff --git a/Roboterfabrik/src/Domäne/R2D2.java b/Roboterfabrik/src/Domäne/R2D2.java index e17ba63..edba334 100644 --- a/Roboterfabrik/src/Domäne/R2D2.java +++ b/Roboterfabrik/src/Domäne/R2D2.java @@ -50,5 +50,8 @@ public class R2D2 extends Roboter { public int getId() { return id; } + public RobotType getRobotType () { + return this.robotType; + } } diff --git a/Roboterfabrik/src/Domäne/RobotFactory.java b/Roboterfabrik/src/Domäne/RobotFactory.java index 7657630..1f83742 100644 --- a/Roboterfabrik/src/Domäne/RobotFactory.java +++ b/Roboterfabrik/src/Domäne/RobotFactory.java @@ -70,4 +70,14 @@ public RobotFactory (String name) { Roboter r = findeRoboter(id); return r.getLastException(); } + + public String datenDesRoboters (int id) { + Roboter r = findeRoboter(id); + String robotType= r.getRobotType().toString(); + String name = r.getName(); + int seriennummer = r.getId(); + String ausgabe = "RoboterType: " + robotType + "; Name: " +name + "; Seriennummer: " + seriennummer; + return ausgabe; + + } } diff --git a/Roboterfabrik/src/Domäne/RobotType.java b/Roboterfabrik/src/Domäne/RobotType.java index 6a89699..deeed5f 100644 --- a/Roboterfabrik/src/Domäne/RobotType.java +++ b/Roboterfabrik/src/Domäne/RobotType.java @@ -1,5 +1,5 @@ package Domäne; public enum RobotType { - R2D2, C3PO + R2D2, C3PO, NEXUS6 } diff --git a/Roboterfabrik/src/Domäne/Roboter.java b/Roboterfabrik/src/Domäne/Roboter.java index e3d79ae..bd66ea1 100644 --- a/Roboterfabrik/src/Domäne/Roboter.java +++ b/Roboterfabrik/src/Domäne/Roboter.java @@ -90,5 +90,7 @@ public abstract class Roboter implements Robot { @Override public abstract int[] think(int[] zahlen) throws RobotException; - + + public abstract RobotType getRobotType(); } + diff --git a/Roboterfabrik/src/facade/Factorysystem.java b/Roboterfabrik/src/facade/Factorysystem.java index bfe0b42..f9f1268 100644 --- a/Roboterfabrik/src/facade/Factorysystem.java +++ b/Roboterfabrik/src/facade/Factorysystem.java @@ -49,4 +49,8 @@ public class Factorysystem { return robotFactory.letzterFehler(id); } + + public String roboterDaten (int id) { + return robotFactory.datenDesRoboters(id); + } } diff --git a/Roboterfabrik/src/ui/Factory.java b/Roboterfabrik/src/ui/Factory.java index 3566fdd..fd86cde 100644 --- a/Roboterfabrik/src/ui/Factory.java +++ b/Roboterfabrik/src/ui/Factory.java @@ -1,11 +1,7 @@ package ui; import java.util.ArrayList; -import java.util.Arrays; import java.util.Scanner; - -import Domäne.C3PO; -import Domäne.R2D2; import facade.Factorysystem; import tpe.exceptions.roboter.exceptions.RobotException; @@ -80,6 +76,7 @@ public class Factory { System.out.println("2 -> AN/AUS machen"); System.out.println("3 -> Roboter sprechen lassen"); System.out.println("4 -> Letzte Fehlermeldung auslesen"); + System.out.println("5 -> Daten abrufen"); System.out.println("9 -> Zurück ins Hauptmenü"); System.out.print("> "); int input = Integer.parseInt(sc.nextLine()); @@ -97,6 +94,7 @@ public class Factory { case 4: letzteFehlermeldung(id); break; + case 5: datenAbruf(id); break; case 9: break loop; } @@ -165,5 +163,9 @@ public class Factory { System.out.println (factorysystem.fehlerAuslesen(id)); } + + private void datenAbruf(int id) { + System.out.println(factorysystem.roboterDaten(id)); + } } \ No newline at end of file