weitere Implementierung Nexus6 und Random ID bei R2D2 (noch nicht final)

main
Lukas Berens 2023-01-07 11:19:18 +01:00
parent 86e042a743
commit 6807b436c5
2 changed files with 60 additions and 4 deletions

View File

@ -1,5 +1,58 @@
package tpe.exceptions.roboter; package tpe.exceptions.roboter;
public class Nexus6 { import tpe.exceptions.roboter.exceptions.RobotException;
public class Nexus6 implements RobotControl, RobotInstructions {
private static int id=19281982;
private static String name="Pris";
private static boolean powerSwitch=false;
private static Nexus6 instance = new Nexus6(id, name, powerSwitch);
private Nexus6(int id, String name, boolean powerSwitch) {
super();
}
public static Nexus6 getInstance() {
return instance;
}
@Override
public String speak(int[] zahlen) {
// TODO Auto-generated method stub
return null;
}
@Override
public int[] think(int[] zahlen) {
// TODO Auto-generated method stub
return null;
}
public int getId() {
return id;
}
@Override
public String getName() {
return name;
}
@Override
public void triggerPowerSwitch() {
powerSwitch=false;
}
@Override
public boolean isPowerOn() {
return powerSwitch;
}
@Override
public RobotException getLastException() {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -1,10 +1,10 @@
package tpe.exceptions.roboter; package tpe.exceptions.roboter;
import java.util.*;
import tpe.exceptions.roboter.exceptions.RobotException; import tpe.exceptions.roboter.exceptions.RobotException;
import tpe.exceptions.roboter.exceptions.RobotMagicValueException; import tpe.exceptions.roboter.exceptions.RobotMagicValueException;
public class R2D2 implements RobotControl, RobotInstructions { public class R2D2 implements RobotControl, RobotInstructions {
private static int counter = 0;
private String name; private String name;
private boolean powerSwitch; private boolean powerSwitch;
private int id; private int id;
@ -13,11 +13,14 @@ public class R2D2 implements RobotControl, RobotInstructions {
public R2D2(String name, boolean powerSwitch) { public R2D2(String name, boolean powerSwitch) {
super(); super();
id = 0+counter; id = createId();
this.name = name; this.name = name;
this.powerSwitch = powerSwitch; this.powerSwitch = powerSwitch;
} }
private int createId() {
Random randomID = new Random();
return randomID.nextInt(10000);
}
@Override @Override
public int getId() { public int getId() {