Results 1 to 6 of 6
Like Tree2Likes
  • 1 Post By DarrylBurke
  • 1 Post By JosAH

Thread: Need Help with Intro to Programming Class

  1. #1
    DesertFlower is offline Member
    Join Date
    Oct 2012
    Rep Power

    Question Program won't move my bot properly

    New to Java programming and need help with the following code. Compiles with no problems but bot will not most past line 17 when program runs. Please be patient with me, I'm new...

    Java Code:
    1 import becker.robots.*;
     2 /**
     3 is a robot designed to pick up trash cans in a neighborhood.
     4 */
     5 public class ACMETrashTruck extends RobotGB implements SanitationEngineer
     6 {
     8 /**creates a ACMETrashTruck using only the caller provided values.
     9    */
    10     public ACMETrashTruck(CityGB city, int street, int avenue, Direction direction)
    11     {
    12         super(city,street,avenue,direction);
    13 }
    15    //robot collects neighborhood trash  
    16          public void collectNeighborhood()
    17          {  this.moveForward(); //this is the only thing he does.  The bot stops moving, it’s like he doesn’t understand what collectEastbound means.  I know this only because after line 17 I added a turnRight command and he did it but nothing else beyond that.)
    18             while(this.canSeeThing())
    19          {
    20          this.collectEastbound();
    21          this.moveForward();
    22          this.collectWestbound();
    23         }
    24 }       
    25         //method of collecting eastbound trash
    26         public void collectEastbound()
    27         {
    28        while(this.canSeeThing());
    29         {
    30             this.pickupThing();
    31             this.moveForward();
    32         }
    33         this.turnRight();
    34         this.moveForward();
    35         this.turnRight();
    36         }
    37         //method of collecting westbound trash
    38         public void collectWestbound()
    39         {
    40         while(this.canSeeThing());
    41         {
    42             this.pickupThing();
    43             this.moveForward();
    44         }
    45         this.turnLeft();
    46         this.moveForward();
    47         this.turnLeft();
    48    }    
    49    // Add methods as required. Be sure to prefix them with description of what they do. See line 7-9 as an example.
    50    // Hint: Compile this file and see what the compiler tells you is missing.
    51 }
    Last edited by DesertFlower; 10-18-2012 at 11:31 PM. Reason: Edited for length and learned how to post code

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: Need Help with Intro to Programming Class

    First off, please don't waste time complaining about your instructor. Many people here learned Java without the aid of an instructor, fellow students, or any of the other perks you get from actually enrolling in a class. Plus 75% of people who come here are going to move on instead of reading the wall of text.

    Secondly, please use the code tags when posting code. Unformatted code is pretty much impossible to read.

    Finally, did you try to compile this? What happens?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Need Help with Intro to Programming Class

    DesertFlower likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Need Help with Intro to Programming Class

    Maybe this doesn't see anything at line #18; add a couple of System.out.println( ... ) statements at 'important' points (such as System.out.println(this.canSeeThing()) before that while loop) and see what happens. Also, that semi colon in line #28 doesn't belong there; maybe there are more similar mistakes in your code, I didn't check.

    kind regards,

    DesertFlower likes this.
    Build a wall around Donald Trump; I'll pay for it.

  5. #5
    DesertFlower is offline Member
    Join Date
    Oct 2012
    Rep Power

    Default Re: Need Help with Intro to Programming Class

    Thank you Jos, it was the semicolons. Your patience and kindness is much appreciated.

  6. #6
    DesertFlower is offline Member
    Join Date
    Oct 2012
    Rep Power

    Default Re: Need Help with Intro to Programming Class

    Quote Originally Posted by DarrylBurke View Post
    Thank you for the links. I think I've got it now. Noobs can be so annoying-I know.

Similar Threads

  1. Programming Logic Class
    By knightwriter in forum New To Java
    Replies: 7
    Last Post: 11-10-2011, 03:44 PM
  2. Replies: 1
    Last Post: 08-25-2010, 10:07 AM
  3. Replies: 1
    Last Post: 10-02-2009, 01:35 AM
  4. Replies: 14
    Last Post: 05-28-2009, 05:44 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