From 7f02505f2aaaaa0f3cb0670b8ab827582f3048ca Mon Sep 17 00:00:00 2001 From: cedri Date: Sat, 7 Jan 2023 21:16:23 +0100 Subject: [PATCH] Speak Methode implementiert --- .../src/domain/Robotermodell.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Robbie-Management-System/src/domain/Robotermodell.java b/Robbie-Management-System/src/domain/Robotermodell.java index 9c761e1..c72248c 100644 --- a/Robbie-Management-System/src/domain/Robotermodell.java +++ b/Robbie-Management-System/src/domain/Robotermodell.java @@ -1,5 +1,7 @@ package domain; +import java.util.Arrays; + import exceptions.RobotException; import roboterSystem.Robot; @@ -48,8 +50,21 @@ public abstract class Robotermodell implements Robot { @Override public String speak(int[] zahlen) throws RobotException { - // TODO Auto-generated method stub - return null; + String hilfszeichen; + 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(); } } -- 2.43.0