sorting umgebaut

main
Philipp3107 2022-12-14 11:08:49 +01:00
parent 2a68c15468
commit 542ac31f89
1 changed files with 26 additions and 13 deletions

View File

@ -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!");
}
}
}