diff --git a/docs/PM2_ClassDiagram.drawio b/docs/PM2_ClassDiagram.drawio
index e6ee161..a8aea87 100644
--- a/docs/PM2_ClassDiagram.drawio
+++ b/docs/PM2_ClassDiagram.drawio
@@ -1 +1 @@
-7VvbcqM4EP0aV2UesmUuxs5jbGdmU+Xszo5nazKPCiigipAoIcd2vn5bSFwMxEsmZrOp8GTUagnU56i71eCRs4h3XwRKohseYDqyx8Fu5CxHtm25Mwd+lGSvJdOZpQWhIIFRKgVr8oSNcGykGxLg9EBRck4lSQ6FPmcM+/JAhoTg20O1e04P75qgEDcEax/RpvQHCWSkpTN7Wsp/xySM8jtb3oXuiVGubFaSRijg24rIuRo5C8G51FfxboGpMl5uFz3u8zO9xYMJzGSXARcr7+ruJnlKf/jkj5+3ePXX39vziZ7lEdGNWfB3vJNXAZFcmMeW+9wW6ZbEFDFoze85k2vTY0EbURIyuPbhYbAAwSMWkoAZL02H5AlI/YjQYIX2fKMeOZXIf8hb84gL8gTTImrmhG4hDSNs70BjrUaCeAxSgVPQ+ZrbwaqJbtDuQHGFUmkEPqcUJSm5K5YRIxESNudS8tgoNc1sLK9WiHcVkTH7F8xjLMUeVEzvxDDAbAEnb29LQhUsiSpk8owMGQ6HxcwlzHBhkH4B6tMG6g2sKclwTqXgDwXzlYnuCaULToEezpLxTCkHn+J72QJ9TIKAZpMlyCcs/K6osDy3SskqG7h0Ssk3YwUlElwiiTRIChGK7jD9ylMiCVfzC607TzhhMjPVZD6aLDOJkAvOYBGIZOhhAH+LFQFacD26Qf4dbIMuMLUTuLOesJ01sE0EeUQSZ/giQEb1cpjDHt+AWc7WUoDBjc2U0wzTTw06wOJlQYca/C9nhHYGh+C7TfCViMPYe5r5zQh4hFkLIQ6Bn4OxF+PfJtlyFtC2yvabscJxu7EiZ8/JaWHZrZ5+8PEn8vHexaGTLxKYCuKW14b4uC8vbzktbh7WOr4UAu1XBGxke1TBYlyA7YV6D4xlGzUGH9C+o14TGtop0ZsTcIfA3x+8E7sbvH1FfquZzOv9joLgDEI6sMqxtLubB5s43p+xmhR0BU4o8nFbF2EBGKIuDbFUgaR+A3XkwzSbZnAjp+WZ1zGyWG5vkcVrME0fGVc8JA9DTnGinMKZ1Q6O7rQj8pPekG8eHXUaaVKGwgWs96nE8Z8b1aVwqjqHwSEcdQheZ568MK+Yun2xonnoHPKKk8FrjTs6/N4Si4tnEguYPuLBmdwn+NPIuVReAC4re/0cRHhHhrNED6SYdSOFa/fEirx8UWFFxekPKUAvZQXXcd46+SsWUeKuaK/erYgYDZG++64vdtD7qSDkgX2I9H3A+9YVBPu5imEisi1eO+DrDf8NbZ/p+Ux2Z3fNugAWgotrBjchQVF5fF5lweMYsWBwJqdmW9c6wqy3SNIsR+oM4poNCURPCcRk1jFvtPrzMs06pTonrH3EGOAHsOdXH3THVwnudt3+bmdmvDCXcPuqGtjNKuKQS5wM3ukbFw3sto9M9BsGFOhiQSP4KzfgR9h/uGbJRpruTPWOc4oRq+kKHMPWXCf4aREhgXxw/+ngNXr1GtOO4aO3CrTTwWtgFlyqb/9UUkBRmhJfRXAZ59EdjCL2t9XGT4UHGNo0l3nc1q193toReVu5royCVjlINYoxQYhzWAC9iIecIXpVSp+P8infCB8fgy//IhJSB3y0vmQ2o3qYoyhXYJ0cQVVgiiR5xAeP2wa1ucNXrksEhmJTr1bVqKeYeuVmVEmYxkQzq14eqU2kLdOYKGNesexXkLHDl3QfhYz56+d3R8ZxnYy1imlXMk5q33m61n9Mxg5vYT4KGfPs472T0Zn+omd8azLm5ef3QsZX+L2uVJv9r5n2yzF4WmfayWIwNMu/R2j18k8mztU/
\ No newline at end of file
+
\ No newline at end of file
diff --git a/docs/Äquivalenzklassen.md b/docs/Äquivalenzklassen.md
new file mode 100644
index 0000000..15d6ca6
--- /dev/null
+++ b/docs/Äquivalenzklassen.md
@@ -0,0 +1,16 @@
+#Äquivalenzklassen
+
+### Text.java Index method
+
+|Positiv testcase||
+|:---|:---|
+|1. Case|At least one Word gets used more than 3 times but not more than 3 times in one paragraph && at least one word doesn't get used more than 3 times in the whole text.|
+|2. Case|At least one word gets used more than 3 times in only one paragraph çç at least one word doesn't get used more than 3 times in the whole text.|
+|3. Case|The same word is been written in uppercase and lowercase and is been noticed as the same word.|
+|4. Case|Punctuation marks and spaces are in the text|
+
+|Negativ testcase||
+|:---|:---|
+|1. Case|Empty list of paragraphs|
+|2. Case|Several punctuation marks and or spaces are been used behind|
+
diff --git a/src/Text.java b/src/Text.java
index 57b18fb..df06b53 100644
--- a/src/Text.java
+++ b/src/Text.java
@@ -6,7 +6,6 @@ public class Text {
private final ArrayList text = new ArrayList<>();
private static final String dummyText = "The standard Lorem Ipsum passage, used since the 1500s \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\" Section 1.10.32 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC \"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
- private HashMap> wordbook = new HashMap<>();
/**
* Method to check if a specific Paragraph exists
@@ -136,7 +135,7 @@ public class Text {
* @return ArrayList
*/
public ArrayList index() {
- wordbook = createWordlist();
+ HashMap> wordbook = createWordlist();
String input;
ArrayList output = new ArrayList<>();
ArrayList values;
@@ -165,6 +164,7 @@ public class Text {
* @return HashMap>
*/
private HashMap> createWordlist() {
+ HashMap> wordbook = new HashMap<>();
int counter;
ArrayList numbersList;
String firstLetter;
@@ -172,10 +172,12 @@ public class Text {
for (int i = 0; i < text.size(); i++) {
String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><'/\n]+");
for (String word : words) {
+ //Words get formatted consistently
counter = 1;
firstLetter = word.substring(0, 1);
restLetters = word.substring(1);
word = firstLetter.toUpperCase() + restLetters;
+ //Words are beeing counted
if (wordbook.containsKey(word)) {
numbersList = wordbook.get(word);
counter = numbersList.get(0);
diff --git a/src/TextEditor.java b/src/TextEditor.java
index bb87961..e9b9b48 100644
--- a/src/TextEditor.java
+++ b/src/TextEditor.java
@@ -3,6 +3,7 @@ public class TextEditor {
public static void main(String[] args) {
TextLogik t = new TextLogik();
+
}
}
diff --git a/src/TextLogik.java b/src/TextLogik.java
index ab0126e..4038762 100644
--- a/src/TextLogik.java
+++ b/src/TextLogik.java
@@ -4,6 +4,11 @@ public class TextLogik {
private final Text text;
private final TextOutput textOutput;
+ /**
+ * Initiates a new instance of the class TextLogik.
+ * Contains command instructions for the class Text.
+ * Defined the different cases and appointed to specific commands.
+ */
public TextLogik() {
text = new Text();
textOutput = new TextOutput();
@@ -79,6 +84,12 @@ public class TextLogik {
} while (!"EXIT".equals(command[0]));
}
+ /**
+ * Method to check if a command is numeric.
+ *
+ * @param str command that should be a number.
+ * @return true if the given str matches.
+ */
private boolean isNumeric(String str) {
return str.matches("\\d+");
}
diff --git a/test/TextTest.java b/test/TextTest.java
index d8e2190..1ec7105 100644
--- a/test/TextTest.java
+++ b/test/TextTest.java
@@ -1,28 +1,95 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-
import java.util.ArrayList;
-import java.util.HashMap;
+
public class TextTest {
Text txt;
- ArrayList sListe;
@BeforeEach
void setup() {
txt = new Text();
}
+ /**
+ * Test Method for add and dummy methods
+ */
+ @Test
+ void addTest() {
+ Assertions.assertEquals(0, txt.getText().size());
+ Assertions.assertEquals(false, txt.add(1, "test"));
+ Assertions.assertEquals(false, txt.dummy(1));
+ Assertions.assertEquals(0, txt.getText().size());
+ Assertions.assertEquals(true, txt.add("test1"));
+ Assertions.assertEquals(true, txt.add(1, "test2"));
+ Assertions.assertEquals("test2", txt.getText().get(0));
+ Assertions.assertEquals("test1", txt.getText().get(1));
+ Assertions.assertEquals(true, txt.dummy(2));
+ Assertions.assertEquals(true, txt.dummy());
+ Assertions.assertEquals(true, txt.getText().get(1).equals(txt.getText().get(3)));
+ Assertions.assertEquals(4, txt.getText().size());
+ }
+
+ /**
+ *
+ * Test Method del
+ */
+ @Test
+ void del() {
+ Assertions.assertEquals(true, txt.add("Das ist der erste Beispiel Text."));
+ Assertions.assertEquals(true, txt.add("Das ist der zweite Beispiel Text."));
+ Assertions.assertEquals(true, txt.add("Das ist der dritte Beispiel Text."));
+ Assertions.assertEquals(true, txt.add("Das ist der vierte Beispiel Text."));
+ Assertions.assertEquals(false, txt.del(5));
+ Assertions.assertEquals(true, txt.del(2));
+ Assertions.assertEquals(true, txt.del());
+ Assertions.assertEquals("Das ist der erste Beispiel Text.", txt.getText().get(0));
+ Assertions.assertEquals("Das ist der dritte Beispiel Text.", txt.getText().get(1));
+ }
+
+ /**
+ * Test Method for replace Method
+ */
+ @Test
+ void replace() {
+ Assertions.assertEquals(true, txt.add("Das ist der erste Beispiel Text."));
+ Assertions.assertEquals(true, txt.add("Das ist der zweite Beispiel Text."));
+ Assertions.assertEquals(false, txt.replace(3, "alt", "neu"));
+ Assertions.assertEquals(true, txt.replace(1, "erste", "zweite"));
+ Assertions.assertEquals(true, txt.replace("zweite", "erste"));
+ Assertions.assertEquals("Das ist der zweite Beispiel Text.", txt.getText().get(0));
+ Assertions.assertEquals("Das ist der erste Beispiel Text.", txt.getText().get(1));
+ }
+
+ /**
+ * Test methode for Index method
+ */
@Test
void indexTest() {
- txt.add("Hallo ?Hallo> zusammen !test!");
- txt.add("Hallo, wie zusammen");
- txt.add("Hallo! Wie wie zusammen");
- sListe= txt.index();
- for (String str : sListe){
- System.out.println(str);
- }
- Assertions.assertEquals("Hallo 1, 2, 3",sListe.get(0));
+ ArrayList stringListe;
+
+ //Positiv Testcase One, Three and Four Negativ Testcase Two
+ txt.add("Word word Test");
+ txt.add("Word word etc. !!test zweite... Zeile");
+ txt.add("Lorem ipsum lorem ipsum TEST");
+ stringListe = txt.index();
+ Assertions.assertEquals("Word 1, 2",stringListe.get(0));
+ Assertions.assertEquals("Test 1, 2, 3",stringListe.get(1));
+ //End of Test
+
+ setup();
+
+ //Positiv Testcase Two
+ txt.add("Word word Word Test");
+ stringListe = txt.index();
+ Assertions.assertEquals("Word 1",stringListe.get(0));
+ //End of Test
+
+ setup();
+
+ //Negativ Testcase One
+ stringListe = txt.index();
+ Assertions.assertEquals(0,stringListe.size());
}
}