Re: Karel the robot issues
Quote:
it gives me three errors.
What is the "it" that is giving the errors?
Have you checked for the correct pairing of {}s?
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.
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:
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();
}
}
}