diff --git a/src/uebung08/doc/Image.java b/src/uebung08/doc/Image.java index 7b63d53..a9efdea 100644 --- a/src/uebung08/doc/Image.java +++ b/src/uebung08/doc/Image.java @@ -14,9 +14,8 @@ public class Image implements TextComponent { return 0; } + // immer diese accept methode verwenden @Override - public boolean accept(CountWordsVisitor visitor) { - return visitor.visit(this); - } + public T accept(Visitor visitor) { return visitor.visit(this); } } diff --git a/src/uebung08/doc/Paragraph.java b/src/uebung08/doc/Paragraph.java index ce20b69..bc45c52 100644 --- a/src/uebung08/doc/Paragraph.java +++ b/src/uebung08/doc/Paragraph.java @@ -27,4 +27,7 @@ public class Paragraph implements TextComponent { return wordcount; } + + @Override + public T accept(Visitor visitor) { return visitor.visit(this); } } diff --git a/src/uebung08/doc/Section.java b/src/uebung08/doc/Section.java index ad312ee..d923468 100644 --- a/src/uebung08/doc/Section.java +++ b/src/uebung08/doc/Section.java @@ -20,4 +20,6 @@ public class Section implements TextComponent { return wordcount; } + @Override + public T accept(Visitor visitor) { return visitor.visit(this); } } diff --git a/src/uebung08/doc/TextComponent.java b/src/uebung08/doc/TextComponent.java index 130430e..3491d20 100644 --- a/src/uebung08/doc/TextComponent.java +++ b/src/uebung08/doc/TextComponent.java @@ -3,5 +3,5 @@ package uebung08.doc; public interface TextComponent { public int countWords(); - public boolean accept(Visitor visitor); + public T accept(Visitor visitor); } diff --git a/src/uebung08/doc/Visitor.java b/src/uebung08/doc/Visitor.java index 80e6282..afa9658 100644 --- a/src/uebung08/doc/Visitor.java +++ b/src/uebung08/doc/Visitor.java @@ -2,4 +2,8 @@ package uebung08.doc; public interface Visitor { T visit(TextComponent textComponent); + T visit(Book book); + T visit(Paragraph paragraph); + T visit(Image image); + T visit(Section section); }