Results 1 to 4 of 4
  1. #1
    Chloe is offline Member
    Join Date
    Apr 2014
    Posts
    2
    Rep Power
    0

    Question Helper Method confusion - Assignment Help

    I am having problems with getting the helper method for an assignment to work. I have read through the text based on the section and still unable to get the code working. Any help would gratefully appreciated.

    The question states to edit the train() method so that the method checks to be sure both fitnessfrogs are on track, meaning the black stones numbered 1-11. If neither fitnessfrog is on these stones, they do not move. Every time I test the code out, the frogs move.

    the latest code I have written with the helper method part in green:

    public void train()
    {
    int repetitions = 0;


    this.getSporty1().resetTotalDistanceSprinted();
    this.getSporty2().resetTotalDistanceSprinted();

    this.isOnBlackStones(this.getSporty1());
    this.isOnBlackStones(this.getSporty2());


    repetitions = this.getNumberRepetitions();
    for (int count = 1; count <= repetitions; count++)
    {
    this.getSporty1().sprint();
    this.getSporty2().sprint();
    }
    this.announceFittestFrog();
    }

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,993
    Rep Power
    9

    Default Re: Helper Method confusion - Assignment Help

    The method isOnBlackStones() probably returns a value. It sounds it would be a boolean. You have to store that value in a variable and use it:
    Java Code:
    boolean sporty1OnBlack =  this.isOnBlackStones(this.getSporty1());
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    Chloe is offline Member
    Join Date
    Apr 2014
    Posts
    2
    Rep Power
    0

    Default Re: Helper Method confusion - Assignment Help

    Thank you.

    I'm going to try that suggestion through I have tried using the while loop with it and the method is not working when I execute the method so I guess I'll need to figure out which loop I need to use.

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,993
    Rep Power
    9

    Default Re: Helper Method confusion - Assignment Help

    Just remember that if you need to check this isOnBlackStones() method while the loop is running, to MOVE it to inside the loop. The variable is not magically going to change when it's outside the loop.

    In case you follow up to this post, try not to write "it does not work". Be specific: what did you get, what did you expect? Any error messages are welcome too.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Confusion about using length method
    By rakeshkool27 in forum New To Java
    Replies: 17
    Last Post: 11-28-2013, 03:40 PM
  2. Web services Helper
    By justbeller in forum Web Frameworks
    Replies: 0
    Last Post: 09-17-2012, 03:13 PM
  3. Confusion about main method
    By JohnPringle83 in forum New To Java
    Replies: 9
    Last Post: 05-11-2011, 05:18 AM
  4. Replies: 8
    Last Post: 03-19-2009, 10:38 PM
  5. [SOLVED] calling a boolean method, confusion!!
    By AngrYkIdzrUlE in forum New To Java
    Replies: 18
    Last Post: 03-15-2009, 11:23 AM

Posting Permissions

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