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
|
public class Note {
private String nom;
private double note;
public void affiche(){
System.out.println("la note de " + nom + " est: "+ note);
}
public void setNom (String pNom)
{
this.nom =pNom;
}
public void setNote (double pNote)
{
this.note=pNote;
}
public String getNom() {
return nom;
}
public double getNote() {
return note;
}
//constructeurs
public Note(String pNom, double pNote)
{
this.nom = pNom;
this.note = pNote;
}
}
Classe Evaluation
import java.util.ArrayList;
import java.util.List;
public class Evaluation {
//private List <Note> notes;
private List<Note> notes = new ArrayList<Note>();
public List <Note> getNotes() {
return notes;
}
/*public void setNotes(List <Note> notes) {
this.notes = notes;
}
*/
public void setNote(Note note) {
this.notes.add(note);
}
public double moyenne(){
int totalNote = 0;
for (int i=0; i<this.notes.size(); i++){
totalNote += notes.get(i).getNote();
}
return totalNote / this.notes.size() ;
}
public void resultat(){
for (int i=0; i<this.notes.size(); i++){
System.out.println(notes.get(i).getNom() + " : " + notes.get(i).getNote());
}
}
} |
Partager