From c565fffbffc3bfa06a9efa290b1423bd1c68b5b2 Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 5 Nov 2021 18:36:05 +0100 Subject: [PATCH] Text.java index and createWordlist methode cleanup --- src/Text.java | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Text.java b/src/Text.java index d801203..f26c4ed 100644 --- a/src/Text.java +++ b/src/Text.java @@ -158,13 +158,13 @@ public class Text { } /** - * This method counts all Words in text and adds them together with the paragraph where the word is been used to a Hashmap. + * This method counts all Words in text and adds the count together with the paragraph where the word is been used to a Hashmap. * * @return HashMap> */ private HashMap> createWordlist() { int counter; - ArrayList zahlenListe; + ArrayList numbersList; String firstLetter; String restLetters; for (int i = 0; i < text.size(); i++) { @@ -175,20 +175,20 @@ public class Text { restLetters = word.substring(1); word = firstLetter.toUpperCase() + restLetters; if (wordbook.containsKey(word)) { - zahlenListe = wordbook.get(word); - counter = zahlenListe.get(0); - zahlenListe.remove(0); - zahlenListe.add(0, counter + 1); + numbersList = wordbook.get(word); + counter = numbersList.get(0); + numbersList.remove(0); + numbersList.add(0, counter + 1); - if (zahlenListe.get(zahlenListe.size() - 1) < i + 1) { - zahlenListe.add(i + 1); + if (numbersList.get(numbersList.size() - 1) < i + 1) { + numbersList.add(i + 1); } } else { - zahlenListe = new ArrayList<>(); - zahlenListe.add(counter); - zahlenListe.add(i + 1); + numbersList = new ArrayList<>(); + numbersList.add(counter); + numbersList.add(i + 1); } - wordbook.put(word, zahlenListe); + wordbook.put(word, numbersList); } } return wordbook;