solved Task 3
This commit is contained in:
parent
472af19faf
commit
77042b8d85
|
@ -11,20 +11,16 @@ public class RankingListServer implements CommandExecutor {
|
|||
String[] entry = listEntry.split(";");
|
||||
competitorList.add(new Competitor(0, entry[0], entry[1]));
|
||||
}
|
||||
competitorList.sort(new AlphaComparatorCompetitor());
|
||||
int rank = 1;
|
||||
for(Competitor competitor : competitorList){
|
||||
competitor.setRank(rank);
|
||||
rank++;
|
||||
}
|
||||
return competitorList;
|
||||
}
|
||||
|
||||
public String createSortedText(List<Competitor> competitorList) {
|
||||
// TODO Implement
|
||||
competitorList.sort(new AlphaComparatorCompetitor());
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
int rank = 1;
|
||||
for (Competitor competitor : competitorList) {
|
||||
competitor.setRank(rank);
|
||||
stringBuilder.append(rank).append(" ").append(competitor.getName()).append(" ").append(competitor.getTime()).append("\n");
|
||||
rank++;
|
||||
}
|
||||
|
@ -33,7 +29,11 @@ public class RankingListServer implements CommandExecutor {
|
|||
|
||||
public String createNameList(List<Competitor> competitorList) {
|
||||
// TODO Implement
|
||||
return "";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Competitor competitor : competitorList) {
|
||||
stringBuilder.append(competitor.getName()).append(" ").append(competitor.getTime()).append("\n");
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public String execute(String rankingList) {
|
||||
|
|
Loading…
Reference in New Issue