finished TableofContents

This commit is contained in:
2024-06-08 19:49:45 +00:00
parent 81ea768dca
commit 85e8396ce9
3 changed files with 40 additions and 5 deletions

View File

@@ -29,13 +29,20 @@ public class Book {
}
public String tableOfContents() {
List<String> res = new ArrayList<>();
List<String> gesamt = new ArrayList<>();
for (int i = 0; i < content.size(); i++) {
List<String> res = new ArrayList<>();
res.addAll(content.get(i).accept(new TableOfContentsVisitor()));
for (String string : res) {
string = i +"." + string;
gesamt.add(string);
}
for (TextComponent textComponent : content) {
res.addAll(textComponent.accept(new TableOfContentsVisitor()));
}
return res.toString();
return gesamt.toString();
}
public int countWordsByVisitor() {