diff --git a/1ano/2semestre/poo/src/aula11/ex1/WordPairCounter.java b/1ano/2semestre/poo/src/aula11/ex1/WordPairCounter.java index 1eee2b6..8549816 100644 --- a/1ano/2semestre/poo/src/aula11/ex1/WordPairCounter.java +++ b/1ano/2semestre/poo/src/aula11/ex1/WordPairCounter.java @@ -8,20 +8,7 @@ import java.util.*; public class WordPairCounter { public static void main(String[] args) { - TreeMap> wordPairs = new TreeMap<>() { - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (String word1 : this.keySet()) { - sb.append(word1).append("={"); - for (String word2 : this.get(word1).keySet()) { - sb.append(word2).append("=").append(this.get(word1).get(word2)).append(", "); - } - sb.delete(sb.length()-2, sb.length()).append("}\n"); - } - return sb.toString(); - } - }; + TreeMap> wordPairs = new TreeMap<>(); String text = ""; Path path = Paths.get((new Scanner(System.in)).nextLine()); @@ -42,6 +29,6 @@ public class WordPairCounter { word1Pair.put(word2, word1Pair.getOrDefault(word2, 0) + 1); } - System.out.println(wordPairs); + wordPairs.entrySet().forEach(System.out::println); } }