Merge branch 'master' of https://gitty.informatik.hs-mannheim.de/2122158/PR2-Roboterfabrik.git
commit
c2a3cdbeb0
|
@ -6,9 +6,9 @@ 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;
|
private int id;
|
||||||
static int idZähler = 0;
|
private static int idZähler = 0;
|
||||||
RobotType robotType;
|
private RobotType robotType;
|
||||||
|
|
||||||
|
|
||||||
R2D2 (String name){
|
R2D2 (String name){
|
||||||
|
@ -18,14 +18,6 @@ public class R2D2 extends Roboter {
|
||||||
idZähler++;
|
idZähler++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String speak(int[] zahlen) throws RobotException {
|
|
||||||
String ausgabe = "";
|
|
||||||
for (int i = 0; i < zahlen.length; i++) {
|
|
||||||
ausgabe = ausgabe + zahlen[i] +",";
|
|
||||||
}
|
|
||||||
return ausgabe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] think(int[] zahlen) throws RobotException {
|
public int[] think(int[] zahlen) throws RobotException {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package Domäne;
|
package Domäne;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import tpe.exceptions.roboter.Robot;
|
import tpe.exceptions.roboter.Robot;
|
||||||
import tpe.exceptions.roboter.RobotException;
|
import tpe.exceptions.roboter.RobotException;
|
||||||
|
|
||||||
|
@ -53,8 +55,18 @@ public abstract class Roboter implements Robot {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String speak(int[] zahlen, RobotType robotType) throws RobotException {
|
||||||
public abstract String speak(int[] zahlen) throws RobotException;
|
if (robotType == RobotType.R2D2) {
|
||||||
|
String ausgabe = "";
|
||||||
|
Stream.of(zahlen).forEach(n -> ausgabe = ausgabe + n + ",");
|
||||||
|
return ausgabe;
|
||||||
|
}
|
||||||
|
else if (robotType == RobotType.C3PO) {
|
||||||
|
String ausgabe = "";
|
||||||
|
Stream.of(zahlen).forEach(n -> ausgabe = ausgabe + n + ";");
|
||||||
|
return ausgabe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue