I am new to java and want to create a resultlist that looks something like this:
First the user inputs the event, then the list of results are shown (placement to the left, result and name).
Command> Javelin
Results for Javelin
1 86,00 William Mandela
2 83,50 Arthur Dent
3 63,00 Donald Dublett
4 58,00 Hawkeye Pierce
5 40,00 Ada Lovelace
If there are two or more identical results the Athletes share the placement.
Command> 100 meters
Results for 100 meters
1 11,30 Donald Dublett
2 12,40 Tricia Mcmillan
2 12,40 Alan Turing
4 13,00 William Mandela
5 15,00 Arthur Dent
5 15,00 Ada Lovelace
7 16,00 Hawkeye Pierce
This is what i got so far, but it does not work.
for (int m = 1; m < ResultList.gamesResults.size(); m++) {
System.out.println(counter++ + ". " + ResultList.gamesResults.get(m-1).getResult());
if (ResultList.gamesResults.get(m).getResult() == ResultList.gamesResults.get(m-1).getResult()) {
System.out.println(counter + ". " + ResultList.gamesResults.get(m).getResult());
}
}
The name part is not important right now. What im trying to do is kind of a bubble sort, but instead i just check for same results. What do you guys think? Im i wasting my time on this? It feels like im on the right track. What im i missing?!
I don't want to use the Comparator interface, so you know.