Bonjour,
j'ai réaliser cette méthode:
Dans la classe Etudiant:
dans le programme principale :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 public static int addeleve(Etudiant etd){ if (i<student.length | l<perso.length){//test de tableau perso et etudiant atteint student[i]=etd; //je met l'etudiant dans le tableau cellule indice i i=i+1; //j'avance i de 1 } else{ System.out.println(" impossible d'ajouter l'Etudiant : maximum atteint"); } return i;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 compte=0; for(compte=0;compte <Etudiant.i;compte++){ System.out.println("Etudiant"+compte+" : "+Etudiant.student[compte].unetudiant.unepersonne.nom + " "+Etudiant.student[compte].unetudiant.unepersonne.prenom+" "+Etudiant.student[compte].unetudiant.unepersonne.email+" "+Etudiant.student[compte].unetudiant.note); }
Donc on devrait afficher les etudiants qui ont ete mis dans le tableau, mais la ça ne marche pas le tableau est rempli uniquement par le dernier étudiant :
TEST
zzz aaa //creation personne
Etudiant: zzz aaa 10.0 // etudiant extend personne
//etudiant 1 indice 0 du tableau
FGHFGHFGH qsdsdghjhjhkjk //creation personne
Etudiant: FGHFGHFGH qsdsdghjhjhkjk 78.0
//etudiant 2 indice 1 du tableau
quand on demande le listage du tableau :
Etudiant0 : FGHFGHFGH qsdsdghjhjhkjk 78.0
Etudiant1 : FGHFGHFGH qsdsdghjhjhkjk 78.0
Comme si la dernière valeur avait écrasé les autres...
l'etudiant 1 n'apparait pas à l'indice 0 !!!
Merci de votre aide
Partager