Results 1 to 6 of 6
- 10-18-2012, 12:32 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 7
- Rep Power
- 0
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 { 7 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 } 14 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
- 10-18-2012, 03:03 PM #2
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 - Play indie games, learn from game tutorials and source code, upload your own games!
- 10-18-2012, 03:45 PM #3
Re: Need Help with Intro to Programming Class
Forum Rules -- particularly the third paragraph
Guide For New Members
BB Code List - Java Programming Forum
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 10-18-2012, 07:25 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-18-2012, 11:30 PM #5
Member
- Join Date
- Oct 2012
- Posts
- 7
- Rep Power
- 0
Re: Need Help with Intro to Programming Class
Thank you Jos, it was the semicolons. Your patience and kindness is much appreciated.
- 10-18-2012, 11:36 PM #6
Member
- Join Date
- Oct 2012
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Programming Logic Class
By knightwriter in forum New To JavaReplies: 7Last Post: 11-10-2011, 03:44 PM -
Programming RFID (base on http://docs.sun.com/source/819-4684/RFID-intro.html)
By rey1024 in forum Advanced JavaReplies: 1Last Post: 08-25-2010, 10:07 AM -
Help with implement class programming assignment
By ALH813 in forum EclipseReplies: 1Last Post: 10-02-2009, 01:35 AM -
E:\IT 215 Java Programming\public class Inventory.java:39: class, interface, or enum
By tlouvierre in forum New To JavaReplies: 14Last Post: 05-28-2009, 05:44 AM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks