package uebung08.doc;

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

public class ToTextVisitor implements Visitor<String>{
    
    public String visit(Image image) {
        return image.getCaption();
    }

    public String visit(Paragraph paragraph) {
        return "";   
    }

    public 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.add(section.getContent().get(i).accept(this));

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

        }

        return gesamt.toString();
    }
}
