package uebung08.doc;

import java.util.List;

public class Section implements TextComponent {

    private String header;
    private List<TextComponent> content;

    public Section(String header, List<TextComponent> content) {
        this.header = header;
        this.content = content;
    }

    public int countWords() {
        int wordcount = 0;
        for (TextComponent textComponent : content) {
            wordcount += textComponent.countWords();
        }
        return wordcount;
    }

    public List<TextComponent> getContent() {
        return content;
    }

    public String getHeader() {
        return header;
    }

    @Override
    public <T> T accept(Visitor<T> visitor) { return visitor.visit(this); }
}
