Methoden Robotermodell ergänzt + kleine Umstrukturierung

Aufsteigende_Sortierung
cedri 2023-01-07 20:00:44 +01:00
parent 4498d916dd
commit 54adc38a93
6 changed files with 89 additions and 36 deletions

View File

@ -1,8 +1,9 @@
package domain; package domain;
import exceptions.RobotException;
import roboterSystem.Robot; import roboterSystem.Robot;
public class C3PO extends Robotermodelle implements Robot { public class C3PO extends Robotermodell implements Robot {
private int zähler = 10000; private int zähler = 10000;
@ -12,6 +13,10 @@ public class C3PO extends Robotermodelle implements Robot {
zähler++; zähler++;
} }
@Override
public int[] think(int[] zahlen) throws RobotException {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -1,8 +1,9 @@
package domain; package domain;
import exceptions.RobotException;
import roboterSystem.Robot; import roboterSystem.Robot;
public class R2D2 extends Robotermodelle implements Robot { public class R2D2 extends Robotermodell implements Robot {
private int zähler = 0; private int zähler = 0;
@ -12,5 +13,10 @@ public class R2D2 extends Robotermodelle implements Robot {
zähler++; zähler++;
} }
@Override
public int[] think(int[] zahlen) throws RobotException {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -1,17 +0,0 @@
package domain;
import roboterSystem.Robot;
public class RobotFactory {
public static Robot RobotFactory (String modell, String name) {
switch(modell) {
case "C3PO":
return new C3PO(name);
case "R2D2":
return new R2D2(name);
}
return null;
}
}

View File

@ -0,0 +1,55 @@
package domain;
import exceptions.RobotException;
import roboterSystem.Robot;
public abstract class Robotermodell implements Robot {
private int iD;
private String name;
private boolean power = true;
public void setName(String name) {
this.name = name;
}
public void setiD(int iD) {
this.iD = iD;
}
@Override
public int getId() {
return iD;
}
@Override
public String getName() {
return name;
}
@Override
public void triggerPowerSwitch() {
if (power == true) {
power = false;
} else {
power = true;
}
}
@Override
public boolean isPowerOn() {
return power;
}
@Override
public RobotException getLastException() {
// TODO Auto-generated method stub
return null;
}
@Override
public String speak(int[] zahlen) throws RobotException {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,16 +0,0 @@
package domain;
public class Robotermodelle {
private int iD;
private String name;
private boolean power = true;
public void setName(String name) {
this.name = name;
}
public void setiD(int iD) {
this.iD = iD;
}
}

View File

@ -0,0 +1,20 @@
package main;
import domain.C3PO;
import domain.R2D2;
import domain.RobotType;
import domain.Robotermodell;
public class RobotFactory {
public static Robotermodell robotFactory (RobotType modell, String name) {
switch(modell) {
case C3PO:
return new C3PO(name);
case R2D2:
return new R2D2(name);
}
return null;
}
}