package com.dis;

import java.util.*;

/**
 * Created by Kasimir on 04.07.2017.
 */
public class DisplayData {
    public List<LocationData> allData;

    public DisplayData(){
        allData = new ArrayList<LocationData>();
    }

    public void add(String city, Date date, String article, int amount) {
        boolean cityavailable = false;
        for (LocationData cd: allData)
        {
            if(cd.cityName.equals(city))
            {
                cd.add(date,article,amount);
                cityavailable = true;
                break;
            }
        }
        if(!cityavailable && city != null)
        {
            LocationData newData = new LocationData(city);
            newData.add(date,article,amount);
            allData.add(newData);
        }
    }

    public  List<List<String>> makeOutput(List<String> headers)
    {
        List<List<String>> result = new ArrayList<List<String>>();

        for(LocationData cd: allData)
        {
            List<List<String>> cityresults = cd.makeOutput(headers);
            result.addAll(cityresults);
        }
        return result;
    }


}
@@ -1079,32 +1079,788 @@
 lts);%0A        %7D%0A
+        List%3CString%3E total = new ArrayList%3C%3E();%0A        total.add(%22Insgesamt%22);%0A        total.add(%22total%22);%0A        for (List%3CString%3E list: result) %7B%0A            if(list.get(1).equals(%22total%22))%0A            %7B%0A                for(int i = 2; i %3C list.size(); i++)%0A                %7B%0A                    if(total.size() %3C list.size())%0A                    %7B%0A                        total.add(%220%22);%0A                    %7D%0A                    int oldvalue = Integer.parseInt(total.get(i));%0A                    int newvalue = Integer.parseInt(list.get(i));%0A                    total.set(i,Integer.toString(oldvalue+newvalue));%0A                    total.set(i,Integer.toString(oldvalue+newvalue));%0A                %7D%0A            %7D%0A        %7D%0A        result.add(total);%0A
         return r

add final total line