diff --git a/src/ch/zhaw/ads/RankingListServer.java b/src/ch/zhaw/ads/RankingListServer.java index 7828dba..b6f23cd 100644 --- a/src/ch/zhaw/ads/RankingListServer.java +++ b/src/ch/zhaw/ads/RankingListServer.java @@ -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 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 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) {