Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: While Loops

  1. #1
    New to the CF scene
    Join Date
    Mar 2017
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    While Loops

    Hi Everyone,
    I am working on a uni assignment, where I am required to move a lady beetle (clara), to the center of any given area (square area, with an uneven number of spaces height and width), place a leaf there and move off to the right and stop there. (Image 1=start, image 2= finish)
    The code is in Java, and I am only allowed to incorporate If and Else statements, and while loops (see code below).

    The commands I can use are also provided below and are quite straightforward.

    My initial idea is to have her move and place a leaf on each place until she puts on in the center, and then go back and pick up the other leaves.
    Any help or ideas as to how to approach this would be greatly appreciated

    -clara-help-jpg
    -clara-help-2-jpg
    -help-3-jpg


    /* PERMITTED COMMANDS
    move(); turnLeft(); turnRight(); treeLeft(); treeRight(); treeFront(); onLeaf(); putLeaf(); removeLeaf();
    JAVA
    if, else, while, &&, ||, !
    NOT ALLOWED TO USE for LOOPS and variables */

    class MyClara extends Clara {
    /**
    * In the 'run()' function you can write your program for Clara
    */
    void run() {
    // TODO: Write your code below
    }
    }

  2. #2
    Super Moderator vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,269
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Is this the same homework assignment you're working on as this? If so, there is no need to start a new thread; the original thread has been moved to the java forum.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  3. #3
    New to the CF scene
    Join Date
    Mar 2017
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes it is, I didn't have email notifications on the original so I wasn't aware, thank you.
    Do I remove this post?

  4. #4
    Super Moderator vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,269
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Nope. I'll just close this thread.

    Thanks for the clarification.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!


 

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
  •