Id und Id Zähler von Roboter in R2D2 verschoben
parent
c3f23ed765
commit
64e39d28e8
|
@ -4,11 +4,14 @@ import tpe.exceptions.roboter.Robot;
|
||||||
import tpe.exceptions.roboter.RobotException;
|
import tpe.exceptions.roboter.RobotException;
|
||||||
|
|
||||||
public class R2D2 extends Roboter {
|
public class R2D2 extends Roboter {
|
||||||
|
int id;
|
||||||
|
static int idZähler = 0;
|
||||||
|
|
||||||
|
|
||||||
R2D2 (String name){
|
R2D2 (String name){
|
||||||
super (name);
|
super (name);
|
||||||
|
this.id = idZähler;
|
||||||
|
idZähler++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,24 +4,24 @@ import tpe.exceptions.roboter.Robot;
|
||||||
import tpe.exceptions.roboter.RobotException;
|
import tpe.exceptions.roboter.RobotException;
|
||||||
|
|
||||||
public abstract class Roboter implements Robot {
|
public abstract class Roboter implements Robot {
|
||||||
int id;
|
|
||||||
String name;
|
String name;
|
||||||
boolean power;
|
boolean power;
|
||||||
static int idZähler = 1;
|
|
||||||
//Roboter wird in einem ausgeschalteten Zustand instanziiert!
|
//Roboter wird in einem ausgeschalteten Zustand instanziiert!
|
||||||
|
|
||||||
Roboter (String name){
|
Roboter (String name){
|
||||||
this.id = idZähler;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.power = false;
|
this.power = false;
|
||||||
idZähler++;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//gibt die ID des Roboters zurück
|
//gibt die ID des Roboters zurück
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public abstract int getId();
|
||||||
return id;
|
|
||||||
}
|
|
||||||
//gibt den Namen des Roboters zurück
|
//gibt den Namen des Roboters zurück
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
Loading…
Reference in New Issue