package lab5;

import java.io.BufferedReader;
import java.util.ArrayList;

import martin.Parse;
import martin.IO;

public class TempAnnee extends ArrayList<TempMois>{

	/*constructor*/
	private TempAnnee(){
		super();
	}

	/*OBJECT*/
	public String toString(){
		String tmp = "          Moyenne des     Moyenne des\n";
		tmp = tmp +  "Mois      temperatures    precipitations\n";
		for(int i=0;i<12;i++)
			tmp = tmp + this.get(i).toString() + "\n";
		tmp = tmp + "fin\n";
		return tmp;

	}

	/*main*/

	public static void main(String [] args) throws Exception{
		BufferedReader in = IO.openReader("meteo.txt");
		TempAnnee annee = new TempAnnee();
		int index=0;

		for (int j=0;j<12;j++){
			//expect name
			annee.add(new TempMois(Parse.read(in)));
			//take number of day
			int cnt = Parse.readInt(in);
			//expect temperature word
			Parse.expect(in, "temperature");
			//expect (
			Parse.expect(in, '(');
			//temperature loop
			double [] temp = new double[cnt];
			for (int i=0;i<cnt;i++)
				temp[i]=Parse.readDouble(in);
			//expect)
			Parse.expect(in, ")");
			//expect precipitation word
			Parse.expect(in, "precipitation");
			//expect(
			Parse.expect(in, '(');
			//precipitation loop
			for (int i=0;i<cnt;i++)
				annee.get(index).add(new Pair<Double,Integer>(temp[i],Parse.readInt(in)));
			//expect)
			Parse.expect(in, ")");

			index++;
		}

		System.out.println(annee.toString());

		in.close();

	}
}
