implemented composite pattern

This commit is contained in:
2024-06-07 15:25:15 +02:00
parent 41743095bd
commit 753d5e2780
12 changed files with 267 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package uebung08.doc;
import java.util.List;
public class Book {
private String title;
private String author;
List<TextComponent> content;
public Book(String author, String title, List<TextComponent> content) {
this.author = author;
this.title = title;
this.content = content;
}
public int countWords() {
int wordcount = 0;
for (TextComponent textComponent : content) {
wordcount += textComponent.countWords();
}
return wordcount;
}
public String toText() {
return "";
}
public String tableOfContents() {
return "";
}
public int countWordsByVisitor() {
return 0;
}
}