Nexus6 Roboter als Singleton umgesetzt

master
Milan Lukic 2023-01-04 14:49:06 +01:00
parent 3bcff6941c
commit a12278c48b
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,47 @@
package Domäne;
import Exception.RobotException;
import Exception.RobotIllegalStateException;
public class Nexus6 extends Roboter {
String name;
int id;
private static Nexus6 pris;
private Nexus6() {
super("Pris");
this.id = 19_281_982;
}
public static Nexus6 getInstance () {
if (pris == null) {
pris = new Nexus6();
}
return pris;
}
@Override
public void triggerPowerSwitch() {
power = false;
}
@Override
public int getId() {
return id;
}
@Override
public int[] think(int[] zahlen)throws RobotException {
return null;
}
}

View File

@ -10,7 +10,7 @@ public RobotFactory (String name) {
this.name = name;
}
public int addRoboter (RobotType robotType) {
public int addRobot (RobotType robotType) {
Roboter roboter;
if (RobotType.R2D2 == robotType) {
@ -27,4 +27,12 @@ public RobotFactory (String name) {
else
return -1;
}
public String getName() {
return name;
}
public Roboter findeRoboter (int id) {
return roboters.get(id);
}
}