UI weiter weweitert. Daten des Roboters können abgerufen werden!

master
Milan Lukic 2023-01-06 15:13:03 +01:00
parent 4d28be7a18
commit 7ffe3886ac
8 changed files with 44 additions and 10 deletions

View File

@ -9,7 +9,7 @@ public class C3PO extends Roboter {
private int id; private int id;
//static int idZähler = 10000; //static int idZähler = 10000;
private RobotType robotType; private RobotType robotType;
RobotException fehler; //RobotException fehler;
public C3PO(String name, int id) { public C3PO(String name, int id) {
super(name); super(name);
@ -51,6 +51,9 @@ public class C3PO extends Roboter {
throw fehler; throw fehler;
} }
public RobotType getRobotType () {
return this.robotType;
}
} }

View File

@ -5,15 +5,17 @@ import tpe.exceptions.roboter.exceptions.RobotIllegalStateException;
public class Nexus6 extends Roboter { public class Nexus6 extends Roboter {
String name; private String name;
int id; private int id;
RobotException fehler; //RobotException fehler;
private static Nexus6 PRIS; private static Nexus6 PRIS;
private RobotType robotType;
private Nexus6() { private Nexus6() {
super("Pris"); super("Pris");
this.id = 19_281_982; this.id = 19_281_982;
robotType = RobotType.NEXUS6;
} }
@ -55,4 +57,12 @@ public class Nexus6 extends Roboter {
} }
@Override
public RobotType getRobotType() {
return this.robotType;
}
} }

View File

@ -50,5 +50,8 @@ public class R2D2 extends Roboter {
public int getId() { public int getId() {
return id; return id;
} }
public RobotType getRobotType () {
return this.robotType;
}
} }

View File

@ -70,4 +70,14 @@ public RobotFactory (String name) {
Roboter r = findeRoboter(id); Roboter r = findeRoboter(id);
return r.getLastException(); 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;
}
} }

View File

@ -1,5 +1,5 @@
package Domäne; package Domäne;
public enum RobotType { public enum RobotType {
R2D2, C3PO R2D2, C3PO, NEXUS6
} }

View File

@ -91,4 +91,6 @@ public abstract class Roboter implements Robot {
@Override @Override
public abstract int[] think(int[] zahlen) throws RobotException; public abstract int[] think(int[] zahlen) throws RobotException;
public abstract RobotType getRobotType();
} }

View File

@ -49,4 +49,8 @@ public class Factorysystem {
return robotFactory.letzterFehler(id); return robotFactory.letzterFehler(id);
} }
public String roboterDaten (int id) {
return robotFactory.datenDesRoboters(id);
}
} }

View File

@ -1,11 +1,7 @@
package ui; package ui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner; import java.util.Scanner;
import Domäne.C3PO;
import Domäne.R2D2;
import facade.Factorysystem; import facade.Factorysystem;
import tpe.exceptions.roboter.exceptions.RobotException; import tpe.exceptions.roboter.exceptions.RobotException;
@ -80,6 +76,7 @@ public class Factory {
System.out.println("2 -> AN/AUS machen"); System.out.println("2 -> AN/AUS machen");
System.out.println("3 -> Roboter sprechen lassen"); System.out.println("3 -> Roboter sprechen lassen");
System.out.println("4 -> Letzte Fehlermeldung auslesen"); System.out.println("4 -> Letzte Fehlermeldung auslesen");
System.out.println("5 -> Daten abrufen");
System.out.println("9 -> Zurück ins Hauptmenü"); System.out.println("9 -> Zurück ins Hauptmenü");
System.out.print("> "); System.out.print("> ");
int input = Integer.parseInt(sc.nextLine()); int input = Integer.parseInt(sc.nextLine());
@ -97,6 +94,7 @@ public class Factory {
case 4: case 4:
letzteFehlermeldung(id); letzteFehlermeldung(id);
break; break;
case 5: datenAbruf(id); break;
case 9: case 9:
break loop; break loop;
} }
@ -166,4 +164,8 @@ public class Factory {
} }
private void datenAbruf(int id) {
System.out.println(factorysystem.roboterDaten(id));
}
} }