diff --git a/domain/R2D2.java b/domain/R2D2.java index 368a61b..2433b74 100644 --- a/domain/R2D2.java +++ b/domain/R2D2.java @@ -40,18 +40,31 @@ public class R2D2 extends RobotBasics { } return arr; } - /* - //Writing all values of the array into a String - String result = ""; - if(arr.length != 0) { - result = "" + arr[0]; - if (arr.length > 1) { - for (int i = 1; i < arr.length; i++) { - result += "," + arr[i]; - } - } - } - return result; - */ + public String ausgabe(int[] input){ + String result = " "; + if(input.length != 0) { + result = " " + input[0]; + for(int i = 1; i < input.length; i++){ + result += "; " + input[i]; + } + return result; + } + return null; + } + + /** + * Die Methode nimmt ein Array aus int entgegen und wandelt diese in einen String um. + * @param input Zahlen, die ausgegeben werden sollen. + * @return String oder null + * @throws RobotException + */ + @Override + public String speak(int[] input) throws RobotException { + if(isPowerOn()){ + return ausgabe(input); + }else{ + throw new RobotIllegalStateException(getName() + " is turned off!"); + } + } } \ No newline at end of file