import java.io.*;
import java.util.Iterator;
import java.util.Vector;


public class MakePool {
	
	public static void main(String[] args) throws ClassNotFoundException
	{
		String nomGroupe = args[0];
		String nomFichierEntree = args[1];
		String nomFichierSortie = args[2];
		
		Pool p = new Pool(nomGroupe,nomFichierEntree);
		
		for(EistiStudent e : p)
		{
			e.setRanking((int)Math.random()*20);
		}
	
		p.toString();
		for (Iterator<EistiStudent> it = p.iterator(OrderType.ASCENDING); it.hasNext(); ) {
			EistiStudent student = it.next();
			System.out.println("   - " + student.toString());
		}
		
		sauvegarder(nomFichierSortie,p);
		// for(exp1;exp2;exp3)
		
		/* 
		 * exp1;
		 * while(exp2)
		 * {
		 * ...
		 * exp3
		 * }
		 * */
		
		
	}
	


	public static void sauvegarder(String nomFichier,Pool p) 
	{
	
		
		try {
			File f = new File(nomFichier);
			FileOutputStream fos = new FileOutputStream(f);
			DataOutputStream dos = new DataOutputStream(fos);
			
			dos.writeChars(p.toString());
			dos.writeChars("\n");
			
			for(Iterator<EistiStudent> it = p.iterator(OrderType.DESCENDING); it.hasNext(); ) {
				EistiStudent e = it.next();
				dos.writeChars(e.toString());
				dos.writeChars("\n");
			}
			// On ferme le ObjectInputStream
			dos.close();
			// On ferme le FileInputStream
			fos.close();
		} catch (FileNotFoundException e) {
		
			e.printStackTrace();
			
		} catch (IOException e) {
		
			e.printStackTrace();
			
		}		
	}



	
}
