weitere Klassen und RobotMagic.. bei R2D2

main
Lukas Berens 2023-01-03 12:14:11 +01:00
parent 5679d63e71
commit 86e042a743
5 changed files with 49 additions and 4 deletions

View File

@ -1,12 +1,15 @@
package tpe.exceptions.roboter;
import tpe.exceptions.roboter.exceptions.RobotException;
import tpe.exceptions.roboter.exceptions.RobotMagicValueException;
public class R2D2 implements RobotControl, RobotInstructions {
private static int counter = 0;
private String name;
private boolean powerSwitch;
private int id;
private RobotMagicValueException robotMagicValueException;
StringBuilder sb = new StringBuilder();
public R2D2(String name, boolean powerSwitch) {
super();
@ -17,6 +20,7 @@ public class R2D2 implements RobotControl, RobotInstructions {
@Override
public int getId() {
return id;
}
@ -46,8 +50,19 @@ public class R2D2 implements RobotControl, RobotInstructions {
@Override
public String speak(int[] zahlen) {
// TODO Auto-generated method stub
return null;
if(robotMagicValueException.invalidNumber(zahlen)==true)
return "42 ist keine gültige Eingabe";
else {
for (int i = 0; i < zahlen.length; i++) {
sb.append(zahlen[i]);
if (i < zahlen.length - 1) {
sb.append(", ");
}
}
String output = sb.toString();
return output;
}
}
@Override
@ -69,5 +84,5 @@ public class R2D2 implements RobotControl, RobotInstructions {
}
return zahlen;
}
}

View File

@ -1,5 +1,6 @@
package tpe.exceptions.roboter.exceptions;
public class RobotException {
}

View File

@ -1,5 +1,16 @@
package tpe.exceptions.roboter.exceptions;
public class RobotMagicValueException {
public class RobotMagicValueException {
public boolean invalidNumber(int[] zahlen) {
boolean error=false;
for(int i =0; i<zahlen.length;i++)
{
if(zahlen[i]==42)
error=true ;
}
return error;
}
}

View File

@ -0,0 +1,13 @@
package tpe.exceptions.roboter.facade;
import tpe.exceptions.roboter.C3PO;
import tpe.exceptions.roboter.R2D2;
public class RobotFactory {
private R2D2 r2d2;
private C3PO c3po;
public int constructRobot() {
}
}

View File

@ -0,0 +1,5 @@
package tpe.exceptions.roboter.ui;
public class UI {
}