Results 1 to 7 of 7
Thread: First of all...
- 01-05-2009, 10:28 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 4
- Rep Power
- 0
First of all...
Hello everybody,
I'm new here and I thought why not say hello :)
Ok now that that's out of the way... :cool:
Can any of you please help me with this Karel/"Java" program I've made ==>
/* This program collects a few beepers
* which are scattered in karel world in the form of towers
* name: beeperPickingKarel
* date: 5 january 2009
*/
import stanford.karel.*;
public class beeperPickerKarel extends SuperKarel {
public void run() {
collectAllBeepers();
dropAllBeepers();
returnBack();
}
----------------------------------------------------------------------------------> Line 18
//This method defines the statements neccesary for Karel to collect all beepers
private void collectAllBeepers() {
while(frontIsClear()) {
collectTheTowerOfBeepers();
}
collectTheTowerOfBeepers();
}
/* This method defines the statements neccesary for Karel to understand
* the collectBeepers() method which contains the statements necessary for Karel->Line29
* to collect the beepers
*/
private void collectTheTowerOfBeepers() {
faceTheTower();
while(beepersPresent()) {
pickBeeper();
move();
}
faceTheGround();
getBackDown();
turnLeft();
}
//This method will let Karel face the tower(North)
private void faceTheTower() {
while(notFacingNorth()) {
turnLeft();
}
}
//This method lets Karel face the ground so he can get back to that direction
private void faceTheGround() {
while(notFacingSouth()) {
turnRight();
}
}
//This method get Karel back down
private void getBackDown() {
while(frontIsClear()) {
move();
}
}
//This method instruct Karel to drop all beepers that were collected
private void dropAllBeepers() {
while(beepersInBag()) {
putBeeper();
}
}
//This method gets Karel back to where he was in the beginning
private void returnBack() {
turnAround();
while(frontIsClear()) {
move();
}
turnAround();
}
}
I tried to figure it out myself but it keeps saying:
Severity and Description Path Resource Location Creation Time Id
Syntax error, insert "}" to complete ClassBody Assignment1 CollectNewspaperKarel.java line 18 1231145885156 48
Severity and Description Path Resource Location Creation Time Id
Syntax error, insert "}" to complete MethodBody Assignment1 CollectNewspaperKarel.java line 29 1231145885156 49
BTW:
1. If you're wondering --> NO, I'm not a stanford student, I just happened to bump on Eric Robert's book on Karel The Robot.
2. Sorry I couldn't get the indentation right... :(
Can anybode please help?
Thanks in advance....Last edited by Tik; 01-05-2009 at 11:46 AM. Reason: Question is asked
- 01-05-2009, 10:58 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you have on line 18 and 29 in your code?
- 01-05-2009, 11:04 AM #3
Member
- Join Date
- Jan 2009
- Posts
- 4
- Rep Power
- 0
removing them doesn't help, if that is what you meant...
thanks anyways...
- 01-05-2009, 11:40 AM #4
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
Eranga ask where is line 18 and line 29
- 01-05-2009, 11:48 AM #5
Member
- Join Date
- Jan 2009
- Posts
- 4
- Rep Power
- 0
Oh, ok.
Thx, i have marked the lines with an arrow and turned the color to dark orange
hope you can help me now....
- 01-05-2009, 12:09 PM #6
Member
- Join Date
- Jan 2009
- Posts
- 4
- Rep Power
- 0
I figured it out!
Somehow Eclips was showing the errors of another program, after deleting that program the program worked without errors but there are still some logical problems :eek:
But thanks anyways guys for your help! :)
- 01-05-2009, 03:13 PM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Please use code tags when you are posting again here. And also clearly state what your question, with the relevant code segment. Reading such a long code segment is mess for other members. Good luck!


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks