package uebung08.doc;

import java.util.ArrayList;
import java.util.List;

public class TableOfContentsVisitor implements Visitor<List<String>>{

    public List<String> visit(Image image) {
     return new ArrayList<>();   
    }

    public List<String> visit(Paragraph paragraph) {
        return new ArrayList<>();   
    }

    public List<String> visit(Section section) {
        List<String> gesamt = new ArrayList<>();

        gesamt.add(" "+ section.getHeader());

        for (int i = 0; i < section.getContent().size(); i++) {
            List<String> res = new ArrayList<>();
            res.addAll(section.getContent().get(i).accept(this));

            for (String string : res) {
                string = i +"." + string;
                gesamt.add(string);
            }

        }

        return gesamt;
    }
}
