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;
|
||||
|
||||
public class R2D2 extends Roboter {
|
||||
|
||||
int id;
|
||||
static int idZähler = 0;
|
||||
|
||||
|
||||
R2D2 (String name){
|
||||
super (name);
|
||||
super (name);
|
||||
this.id = idZähler;
|
||||
idZähler++;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,24 +4,24 @@ import tpe.exceptions.roboter.Robot;
|
|||
import tpe.exceptions.roboter.RobotException;
|
||||
|
||||
public abstract class Roboter implements Robot {
|
||||
int id;
|
||||
|
||||
String name;
|
||||
boolean power;
|
||||
static int idZähler = 1;
|
||||
|
||||
//Roboter wird in einem ausgeschalteten Zustand instanziiert!
|
||||
|
||||
Roboter (String name){
|
||||
this.id = idZähler;
|
||||
|
||||
this.name = name;
|
||||
this.power = false;
|
||||
idZähler++;
|
||||
|
||||
|
||||
}
|
||||
//gibt die ID des Roboters zurück
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public abstract int getId();
|
||||
|
||||
|
||||
//gibt den Namen des Roboters zurück
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
Loading…
Reference in New Issue