Jump to content
  • 0

Fastlist -> Arraylist Acis


L2shaken

Question

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 by L2shaken
Link to comment
Share on other sites

Recommended Posts

  • 0

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 by L2shaken
Link to comment
Share on other sites

  • 0

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 by bravetobe
Link to comment
Share on other sites

  • 0

Just hire AccessDenied to implement head() method to the HashMap, nothing is impossible when AccessDenied is here. ;D

1000$ and done.

Link to comment
Share on other sites

  • 0

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 by bravetobe
Link to comment
Share on other sites

  • 0

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 :/

Link to comment
Share on other sites

  • 0

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:

Link to comment
Share on other sites

  • 0
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 by Tryskell
Link to comment
Share on other sites

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...