Results 41 to 41 of 41
Thread: Help with Assigment needed.
- 01-28-2010, 12:06 PM #41Member
- Join Date
- Jan 2010
- Rep Power
Write a public instance method called advanceAllRacingFrogs() which takes
no argument and returns no value.
Provided that the race is not over, the method should advance each racingFrog
taking part in the race a random number of stones (between 1 and 3 inclusive) to
the right, one stone at a time. For example if all the racingFrogs are selected to run
in the race, racingFrog1 should advance between 1 and 3 steps first, followed
by racingFrog2 and then racingFrog3. However if advancing a racingFrog
causes it to win the race, the remaining racingFrog(s) selected to race should not
move. If the race is over the method should do nothing. To keep the code simple
the selected racingFrogs should move in ascending numerical order (even though
this gives an advantage to the lower numbered racingFrogs).
[To make the race fairer, the order in which the racingFrogs move should be
chosen at random since the one that moves first clearly has an advantage.
However you should not attempt to code this as it would involve a more
sophisticated use of random numbers than is relevant to what this question is
my code so far
public void advanceAllRacingFrogs()
- By lieni in forum New To JavaReplies: 16Last Post: 01-28-2010, 01:06 AM
- By Lyricid in forum New To JavaReplies: 8Last Post: 12-09-2009, 10:34 PM
- By harshalsakpal in forum CLDC and MIDPReplies: 0Last Post: 02-17-2009, 04:53 PM
- By amarchandar in forum New To JavaReplies: 3Last Post: 02-17-2009, 02:59 PM
- By silvia in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:43 AM