Speak Methode implementiert #1

Merged
2210800 merged 1 commits from Sortierung_In_String into main 2023-01-07 21:18:28 +01:00
1 changed files with 17 additions and 2 deletions

View File

@ -1,5 +1,7 @@
package domain; package domain;
import java.util.Arrays;
import exceptions.RobotException; import exceptions.RobotException;
import roboterSystem.Robot; import roboterSystem.Robot;
@ -48,8 +50,21 @@ public abstract class Robotermodell implements Robot {
@Override @Override
public String speak(int[] zahlen) throws RobotException { public String speak(int[] zahlen) throws RobotException {
// TODO Auto-generated method stub String hilfszeichen;
return null; StringBuilder sb = new StringBuilder();
if (this instanceof C3PO) {
hilfszeichen = ";";
} else {
hilfszeichen = ",";
}
Arrays.stream(zahlen)
.forEach(z -> sb.append(z + hilfszeichen + " "));
sb.setLength(sb.length() - 2);
return sb.toString();
} }
} }