restauration de l'API et ajout de possibilité plusieur promo

This commit is contained in:
2022-11-13 15:00:55 +01:00
parent 0eabe2b4bb
commit c06ff537ad
3 changed files with 36 additions and 55 deletions

View File

@@ -22,6 +22,20 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
this.promo=promo;
this.brain=new HashMap<Integer,Groupe>();
this.brain.put(Integer.valueOf(this.promo.getId()),this.promo);
this.addSousGroupe(this.promo);
}
/**
* permet d'ajouter les sous groupe lors de l'initialisation de la promo
* avec un groupe déja créer
*
* @param g le groupe (methode récursive)
*/
private void addSousGroupe(Groupe g){
for(Groupe s:g.getSousGroupes()){
this.brain.put(g.getId(), g);
this.addSousGroupe(s);
}
}
/**
@@ -208,7 +222,6 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
public Set<Etudiant> getEtudiants(String nomEtu){
Set<Etudiant> s=new LinkedHashSet<>();
for(Etudiant e:this.getPromotion().getEtudiants()){
//System.out.println("Comparaison de: \""+nomEtu.toLowerCase()+"\" a \"" + e.getNom().toLowerCase()+"\"");
if((e.getNom()).equals(nomEtu.toString())){
s.add(e);
}
@@ -237,16 +250,4 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
}
return ret;
}
/**
* permet d'ajouter un groupe deja tout fait la factory
*
* @param adable le groupe devant être ajouter
*
*
* @throws java.lang.NullPointerException si le Groupe est null.
*/
public void addGroupe(Groupe adable) {
this.brain.put(adable.getId(), adable);
}
}