cc2k

Untitled

Aug 24th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Pairing= 2 player objects
  2. getPlayerPlayedAgainst = a check if the player played against the opponent, as they can only play 1x against each other.
  3.  
  4. public List<Pairing> getPairingsNextRoundSwiss() {
  5. // check templist met original list en dan remove templist en start over
  6.  
  7. mPairingsRound = new ArrayList<Pairing>();
  8. Collections.sort(mPlayerList, new ScoreComparator());// sort highest
  9. // score
  10.  
  11. List<Player> tempList = new ArrayList<>(mPlayerList);
  12. List<Player> removedList = new ArrayList<>();
  13.  
  14. for (int i = 0; i <= tempList.size() - 1;) {
  15.  
  16. if (!tempList.get(i).getPlayerPlayedAgainst(mPlayerList.get(i))
  17. && !tempList.get(i).equals(mPlayerList.get(i))
  18. && removedList != null
  19. && !removedList.contains(mPlayerList.get(i))) {
  20. mPairingsRound.add(new Pairing(tempList.get(i), mPlayerList
  21. .get(i)));
  22.  
  23. tempList.remove(i);
  24. removedList.add(mPlayerList.get(i));
  25. } else {
  26.  
  27. for (int j = 0; j <= mPlayerList.size() - 1; j++) {
  28. if (!tempList.get(i).getPlayerPlayedAgainst(
  29. mPlayerList.get(j))
  30. && !tempList.get(i).equals(mPlayerList.get(j))
  31. && removedList != null
  32. && !removedList.contains(mPlayerList.get(j))) {
  33. mPairingsRound.add(new Pairing(tempList.get(i),
  34. mPlayerList.get(j)));
  35.  
  36. tempList.remove(i);
  37. removedList.add(mPlayerList.get(i));
  38. break;
  39. }
  40.  
  41. }
  42. }
  43. }
  44.  
  45. return mPairingsRound;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment