implemented composite pattern
This commit is contained in:
37
src/uebung08/doc/Book.java
Normal file
37
src/uebung08/doc/Book.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user