From 9a05956582e1e94a404a6bdada673769868f05d9 Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 5 Nov 2021 11:41:10 +0100 Subject: [PATCH] Text.java method index changed output format --- src/Text.java | 8 ++++++-- test/TextTest.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Text.java b/src/Text.java index 54e52e2..35ba03e 100644 --- a/src/Text.java +++ b/src/Text.java @@ -144,9 +144,13 @@ public class Text { ArrayList values = entry.getValue(); String input = ""; if (values.get(0) >= 3) { - input += key + " "; + input += key + " "; for (int i = 1; i < values.size(); i++) { - input += values.get(i) + ", "; + if(i+1 == values.size()){ + input += values.get(i)+""; + }else { + input += values.get(i) + ", "; + } } output.add(input); } diff --git a/test/TextTest.java b/test/TextTest.java index 46a5d13..d7e78b1 100644 --- a/test/TextTest.java +++ b/test/TextTest.java @@ -20,6 +20,6 @@ public class TextTest { txt.add("Hallo, wie zusammen"); txt.add("Hallo,wie wie zusammen"); sListe= txt.index(); - Assertions.assertEquals("Hallo 1, 2, 3, ",sListe.get(0)); + Assertions.assertEquals("Hallo 1, 2, 3",sListe.get(0)); } }