1. Re: Smallest numbers

Originally Posted by Fubarable
He's not a caveman, he's dutch... wooden shoes, wooden head, wouldn't listen...
Tolls started this! I didn't do anything and Tolls waved his willy-nilly at me! honest!

kindest regards,

Jos (runs ---------------------------------------------------------------> that a'way)

2. Re: Smallest numbers

Ugh...
I'm confused again.
I need to make a method which takes 1 parameter: Player[]
I don't know how many players there is going to be in the array.
How can I make it so it will loop through each of the players and return which one is the best?

Note: I'm not very good at loops.

3. Re: Smallest numbers

Let's start with this: if the method takes (Player[] players) as its parameter, how many times will the for loop loop? From i = 0 to i < what?

4. Re: Smallest numbers

Originally Posted by Fubarable
Let's start with this: if the method takes (Player[] players) as its parameter, how many times will the for loop loop? From i = 0 to i < what?
players.length

5. Re: Smallest numbers

Originally Posted by PhQ
players.length
Exactly, so in fact you do know how many Players will be in the array at the time the method is called. So set a Player bestPlayer variable to refer to the first Player in the array (checking to make sure that there is at least 1 Player in the array), loop through and compare each player against the current "best" Player (however you define this), and then after the loop ends, return the bestPlayer.

6. Re: Smallest numbers

Woah!
I think I've done it.

Page 2 of 2 First 12

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•