L2shaken Posted November 22, 2016 Posted November 22, 2016 (edited) http://imgur.com/a/1oYgm protected int getWinnerTeam() { ArrayList<EventTeam> t = new ArrayList<>(); for (EventTeam team : teams.values()) { if (t.size() == 0) { t.add(team); continue; } if (team.getScore() > t.getFirst().getScore()) { t.clear(); t.add(team); continue; } if (team.getScore() == t.getFirst().getScore()) t.add(team); } if (t.size() > 1) return 0; return t.getFirst().getId(); } getFirst () must be replaced by what? Edited November 22, 2016 by L2shaken Quote
0 L2shaken Posted November 26, 2016 Author Posted November 26, 2016 (edited) http://imgur.com/a/gZoEQ protected L2PcInstance getPlayerWithMaxScore() { L2PcInstance max = players.head().getNext().getKey(); for (L2PcInstance player : players.keySet()) if (players.get(player)[2] > players.get(max)[2]) max = player; return max; } And this error, how can I solve it? Edited November 26, 2016 by L2shaken Quote
0 bravetobe Posted November 28, 2016 Posted November 28, 2016 Up Stop leeching codes... Read the error :) Quote
0 xxdem Posted November 28, 2016 Posted November 28, 2016 Stop leeching codes... Read the error :) he is obviously looking for something ready2go Quote
0 bravetobe Posted November 28, 2016 Posted November 28, 2016 (edited) can you help me? Noone will help u if u cannot help ur self ... Review thats what u "wrote",and ask urself how u can get the max score ... I m not sure if head() supposed to be the head of the collection ,also i m not sure if the code will work but u can google and learn what head/tail is :). Edited November 28, 2016 by bravetobe Quote
0 L2shaken Posted November 28, 2016 Author Posted November 28, 2016 (edited) I have no idea how to fix this :( Edited November 28, 2016 by L2shaken Quote
0 Tessa Posted November 28, 2016 Posted November 28, 2016 Just hire AccessDenied to implement head() method to the HashMap, nothing is impossible when AccessDenied is here. ;D Quote
0 AccessDenied Posted November 28, 2016 Posted November 28, 2016 Just hire AccessDenied to implement head() method to the HashMap, nothing is impossible when AccessDenied is here. ;D 1000$ and done. Quote
0 bravetobe Posted November 28, 2016 Posted November 28, 2016 (edited) Just hire AccessDenied to implement head() method to the HashMap, nothing is impossible when AccessDenied is here. ;D so he wants to get the head from the hashmap or the player with the max score? both laughable... or at least the 1 but wait... that dude leeches only I will grab some popcorn and keep an eye in this topic and how he will actually do (head) that lmao. Edited November 28, 2016 by bravetobe Quote
0 AccessDenied Posted November 28, 2016 Posted November 28, 2016 so he wants to get the head from the hashmap or the player with the max score? both laughable... or at least the 1 but wait... that dude leeches only I will grab some popcorn and keep an eye in this topic and how he will actually do (head) that lmao. What is this head :'( and what is this hashmap :'( ? Help me :/ Quote
0 Tessa Posted November 28, 2016 Posted November 28, 2016 so he wants to get the head from the hashmap or the player with the max score? both laughable... or at least the 1 but wait... that dude leeches only I will grab some popcorn and keep an eye in this topic and how he will actually do (head) that lmao. AccessDenied can find the head, the tail, and wahtever you want in a HashMap... ;D 1000$ and done. A very reasonable price! :lol: Quote
0 Tryskell Posted November 29, 2016 Posted November 29, 2016 (edited) EventTeam winner = null; for (EventTeam team : teams.values()) if (team.getScore() > ((winner == null) ? 0 : winner.getScore())) winner = team; return winner; If you got only 2 teams max, forever, it's easier to simply write both teams and compare team1 and team2 getScore(). If you can't complete or integrate what I wrote, simply forget to open a server for the next 6 months minimum and take time to learn Java. PS : it's generally terrible to return a simple id, which means you must find back the associated team in one way or another after the getWinner(). It's far better then to take back the entire EventTeam which probably holds all useful informations, such as team compo, the score, the id, etc. PS2 : I avoid to use or provide lambdas writting style, first because I don't want to seek the best writting style, second because lambdas is still shady for 90% of ppl, similar to maven vs ant, third because it's the most popular writting style and at least anyone will understand it. Edited November 29, 2016 by Tryskell Quote
Question
L2shaken
http://imgur.com/a/1oYgm
getFirst () must be replaced by what?
Edited by L2shaken87 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.