blob: 6fe7d45cd1496369e56de9b3a53755950c6960d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
package tp2;
import java.util.ArrayList;
public class Promotion {
private ArrayList<Etudiant> listeetudiants;
private int annee;
public Promotion () {
}
public Promotion (int ext_annee) {
listeetudiants= new ArrayList<Etudiant> ();
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<Etudiant> admis () {
ArrayList<Etudiant> ret = new ArrayList<Etudiant>();
for ( int i =0; i < this.getNbEtu(); i ++) {
if ( listeetudiants.get(i).getMoy()>=10) {
ret.add(listeetudiants.get(i));
}
}
return ret;
}
public ArrayList<Etudiant> nouveauxInscritsNonFrancophones() {
ArrayList<Etudiant> ret = new ArrayList<Etudiant>();
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<Etudiant> majors() {
ArrayList<Etudiant> ret = new ArrayList<Etudiant>();
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;
}
}
|