package tp2; import java.util.ArrayList; public class Promotion { private ArrayList listeetudiants; private int annee; public Promotion () { } public Promotion (int ext_annee) { listeetudiants= new ArrayList (); annee = ext_annee; } public int getNbEtu() { return listeetudiants.size(); } public Etudiant getEtu(int n) { return listeetudiants.get(n); } public void Inscrire (String name, /*Date birthyear,*/ int codeIns, int codePays, double note1, double note2, double note3) { listeetudiants.add(new Etudiant(name,codeIns,codePays,note1, note2, note3)); } public double moyenneGenerale () { double totnotes =0; for (int i =0; i < this.getNbEtu();i ++ ) { totnotes += listeetudiants.get(i).getMoy(); } if (getNbEtu()!=0) { return totnotes/this.getNbEtu(); } else return -1; } public void afficheRes () { for (int i =0 ; i < this.getNbEtu();i++) { listeetudiants.get(i).ligneResultats(); } } public Etudiant recherche( String name) { Etudiant ret= new Etudiant(); for (int i =0 ; i < this.getNbEtu();i++) { if ( listeetudiants.get(i).getNom() == name) { ret = listeetudiants.get(i); } } return ret; } public ArrayList admis () { ArrayList ret = new ArrayList(); for ( int i =0; i < this.getNbEtu(); i ++) { if ( listeetudiants.get(i).getMoy()>=10) { ret.add(listeetudiants.get(i)); } } return ret; } public ArrayList nouveauxInscritsNonFrancophones() { ArrayList ret = new ArrayList(); for ( int i =0; i < this.getNbEtu(); i ++) { if ( listeetudiants.get(i).getCodeIns()==0) { if ( listeetudiants.get(i).getCodePays()==2) { ret.add(listeetudiants.get(i)); } } } return ret; } public ArrayList majors() { ArrayList ret = new ArrayList(); double maxmoy = 0; for (int i =0; i < this.getNbEtu();i++) { if ( listeetudiants.get(i).getMoy() > maxmoy) { maxmoy = listeetudiants.get(i).getMoy(); } } for (int i =0; i < this.getNbEtu();i++) { if ( listeetudiants.get(i).getMoy() == maxmoy) { ret.add(listeetudiants.get(i)); } } return ret; } }