Skip to content
Snippets Groups Projects
Commit d765f6c6 authored by Fabien Delecroix's avatar Fabien Delecroix
Browse files

codes smells

parent a63361f5
No related branches found
No related tags found
No related merge requests found
......@@ -19,24 +19,20 @@ public class Resultat {
resultats = new TreeMap<>();
annuaire = new TreeMap<>();
for (int i=0;i<participants.length;i++) {
Participant participant = participants[i];
String nom = participant.nom;
if (annuaire.containsKey(nom)) {
annuaire.get(nom).add(participant);
if (annuaire.containsKey(participants[i].nom)) {
annuaire.get(participants[i].nom).add(participants[i]);
} else {
Set<Participant> set = new HashSet<>();
set.add(participant);
annuaire.put(nom, set);
set.add(participants[i]);
annuaire.put(participants[i].nom, set);
}
resultats.put(participant, new Temps[6]);
resultats.put(participants[i], new Temps[6]);
}
}
public boolean ajout(Participant participant, Temps temps, int etape) {
if (! resultats.containsKey(participant)) return false;
if ((etape < 0) || (etape >= 6)) return false;
Temps[] scores = this.resultats.get(participant);
scores[etape] = temps;
if (! resultats.containsKey(participant) || (etape < 0) || (etape >= 6)) return false;
this.resultats.get(participant)[etape]=temps;
return true;
}
......@@ -44,16 +40,13 @@ public class Resultat {
public String resultat(Participant participant, int etape) {
Temps[] temps = this.resultats.get(participant);
if (temps == null) return null;
else return resultatEtapeToString(participant, etape, temps[etape]);
}
private static String resultatEtapeToString(Participant participant, int etape, Temps temps) {
StringBuilder resultat = new StringBuilder();
resultat.append(participant).append(' ').append(etape).append("->");
if (temps == null) resultat.append("pas présent");
else resultat.append(temps);
return resultat.toString();
else {
StringBuilder resultat = new StringBuilder();
resultat.append(participant).append(' ').append(etape).append("->");
if (temps[etape] == null) resultat.append("pas présent");
else resultat.append(temps[etape]);
return resultat.toString();
}
}
public String afficheEtape(int etape) {
......@@ -92,13 +85,10 @@ public class Resultat {
}
return returned;
}
public Set<Participant> recherche(String nom) {
if (annuaire.containsKey(nom)) {
return annuaire.get(nom);
} else {
return new HashSet<>();
}
if (annuaire.containsKey(nom)) return annuaire.get(nom);
else return new HashSet<>();
}
public static void main(String[] args) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment