From 9fe033ea88c2f705ec18c232873d056e0c229d72 Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:05:53 +0200 Subject: Initial commit --- .../Cours406/src/tp2/Promotion.java | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 sem_4/java/eclipse-workspace/Cours406/src/tp2/Promotion.java (limited to 'sem_4/java/eclipse-workspace/Cours406/src/tp2/Promotion.java') diff --git a/sem_4/java/eclipse-workspace/Cours406/src/tp2/Promotion.java b/sem_4/java/eclipse-workspace/Cours406/src/tp2/Promotion.java new file mode 100644 index 0000000..6fe7d45 --- /dev/null +++ b/sem_4/java/eclipse-workspace/Cours406/src/tp2/Promotion.java @@ -0,0 +1,85 @@ +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; + + + } +} -- cgit v1.2.3