Results 1 to 5 of 5

Thread: Advice needed

  1. #1
    Join Date
    Dec 2011
    Location
    Germany
    Posts
    9
    Rep Power
    0

    Default Advice needed

    Hi guys

    I'm still not very confident in reading tasks, can you please help where I suppose to use if statement, any loops, how many if statements? please

    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 fair, 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 this question’s assessment aims.]

    so my attempt is

    public void advanceAllRacingFrogs()
    {
    while(this.raceOver !=true) //provided is not over
    {
    if(this.getRacingFrog1().getSelected())
    {
    this.advanceRacingFrog(racingFrog1)
    }
    ..... and so on until the loop will go trough all selected frogs

    }

    but what with other statements, where shall i put them, in the same loop other, please all suggestions will be highly appreaciated

    lucas

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,165
    Rep Power
    20

    Default Re: Advice needed

    "
    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.
    "

    That does not imply a loop inside this method.

  3. #3
    Join Date
    Dec 2011
    Location
    Germany
    Posts
    9
    Rep Power
    0

    Default Re: Advice needed

    oh i see, and how many if statements do i need?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,165
    Rep Power
    20

    Default Re: Advice needed

    No idea.
    Read through the description (that sentence in particular) and see how many ifs you can spot. That'll be the minimum, as some might fall out of implementing other bits.

    Actually, I correct myself a bit from the earlier post...that requirement does not imply a loop where you put it, but:
    "
    ...one stone at a time.
    "
    does imply a loop.

  5. #5
    Join Date
    Dec 2011
    Location
    Germany
    Posts
    9
    Rep Power
    0

Similar Threads

  1. Advice needed on DecimalFormat class
    By israelyan in forum New To Java
    Replies: 3
    Last Post: 01-23-2011, 02:34 AM
  2. Advice needed :)
    By kagster in forum New To Java
    Replies: 1
    Last Post: 11-16-2010, 02:04 AM
  3. general advice needed
    By mac in forum New To Java
    Replies: 1
    Last Post: 03-18-2010, 04:25 PM
  4. Advice needed
    By dineshjf in forum Advanced Java
    Replies: 18
    Last Post: 01-09-2009, 04:17 AM
  5. Prerequisite advice needed
    By Hatrabbit in forum New To Java
    Replies: 2
    Last Post: 11-30-2007, 05:38 PM

Tags for this Thread

Posting Permissions

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