Results 1 to 4 of 4
Thread: Karel the robot issues
- 02-01-2012, 10:22 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Karel the robot issues
I have written a code for my comp sci class and i'm nearly 100% sure the code does not do what i need it to do. :p
But when i try to run the program, to see what kind of adjustments i need to make, it gives me three errors.
When i check out what the errors are i cant find a problem with the line its pointing me to.
The errors are:
Description Resource Path Location Type
Syntax error, insert "}" to complete ClassBody DemocracyKarel.java /ProgrammingAssignment1 line 67 Java Problem
Description Resource Path Location Type
Syntax error, insert "enum Identifier" to complete EnumHeaderName DemocracyKarel.java /ProgrammingAssignment1 line 67 Java Problem
Description Resource Path Location Type
Syntax error, insert "EnumBody" to complete EnumDeclaration DemocracyKarel.java /ProgrammingAssignment1 line 67 Java Problem
Line 67 is the very last line of code. The only thing on that line is the closing bracket for the class body that the first error is telling i need to insert.
I have gone over all the code to make sure I didn't forget another closing bracket somewhere and i cant find anything missing. Any help i can on this would be great!
Java Code:import stanford.karel.*; public class DemocracyKarel extends SuperKarel { /* Provides an entry point for Karel to begin execution of commands */ public void run() { while ( frontIsClear() ) { if ( noBeepersPresent() ) { move(); checkRectangle(); } } } private void checkRectangle() { if ( noBeepersPresent() ) { clearChad(); } else { while ( frontIsClear() ) { move(); move(); } } } private void clearChad() { checkTop(); checkBottom(); } private void checkTop() { turnLeft(); move(); while ( beepersPresent() ) { pickBeeper(); } turnAround(); } private void checkBottom() { move(); move(); if ( beepersPresent() ) { pickBeeper(); } else { turnAround(); move(); turnRight(); } } }Last edited by hsustudent; 02-01-2012 at 10:28 PM.
- 02-02-2012, 12:02 AM #2
Re: Karel the robot issues
What is the "it" that is giving the errors?it gives me three errors.
Have you checked for the correct pairing of {}s?
- 02-02-2012, 08:54 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Re: Karel the robot issues
I am using Eclipse Helios for windows and yes I have check all the brackets to make sure they were paired properly.
- 02-02-2012, 09:05 PM #4
Re: Karel the robot issues
What errors do you get from the javac compiler?
I don't recognize the error messages you posted.
This code compiles for me with no errors:
Java Code:public class DemocracyKarel { //extends SuperKarel // Dummy in missing methods boolean frontIsClear() {return true;} void move(){} void turnLeft(){} void turnRight(){} void turnAround(){} void pickBeeper(){} boolean beepersPresent() {return true;} boolean noBeepersPresent() {return true;} /* Provides an entry point for Karel to begin execution of commands */ public void run() { while ( frontIsClear() ) { if ( noBeepersPresent() ) { move(); checkRectangle(); } } } private void checkRectangle() { if ( noBeepersPresent() ) { clearChad(); } else { while ( frontIsClear() ) { move(); move(); } } } private void clearChad() { checkTop(); checkBottom(); } private void checkTop() { turnLeft(); move(); while ( beepersPresent() ) { pickBeeper(); } turnAround(); } private void checkBottom() { move(); move(); if ( beepersPresent() ) { pickBeeper(); } else { turnAround(); move(); turnRight(); } } }Last edited by Norm; 02-02-2012 at 10:20 PM.
Similar Threads
-
Karel the robot: errors during run
By neu_mann in forum New To JavaReplies: 14Last Post: 06-17-2012, 04:12 AM -
Cant run Karel the robot or other kinds of programs in Eclipse
By John1324 in forum EclipseReplies: 1Last Post: 12-07-2011, 07:39 PM -
karel the robot - are methods case sensitive?
By Roee Yossef in forum New To JavaReplies: 1Last Post: 11-07-2011, 08:23 AM -
Super Simple: Importing into Eclipse on a Mac (karel the robot)
By evcrimmi in forum New To JavaReplies: 3Last Post: 07-19-2011, 08:41 PM -
Karel the robot
By vulerious in forum New To JavaReplies: 0Last Post: 07-31-2009, 09:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks