1.16.4: Super Cleanup Karel
does not pass 4th world, please advise, urgent answer needed, 50 pts.
attached image is final result on world 4.
variables are NOT allowed.
public class SuperCleanupKarel extends SuperKarel
{
public void run()
{
ballsTaken();
while(leftIsClear())
{
endUpFacingEast();
ballsTaken();
if(rightIsClear()){
endUpFacingWest();
ballsTaken();
} else {
turnAround();//commentasdfasfdf
}
}
if(rightIsClear())
{
endUpFacingWest();
ballsTaken();
} else {
turnAround();
}
turnLeft();
if(rightIsBlocked())
{
if(frontIsBlocked())
{
turnLeft();
}
}else
{
turnRight();
}
while(frontIsClear())
{
move();
}
turnLeft();
if(frontIsBlocked())
{
turnRight();
if(leftIsBlocked())
{
if(frontIsBlocked())
{
turnLeft();
}
}
turnLeft();
}
}
private void ballsTaken() {
if(ballsPresent()) {
takeBall();
}
while(frontIsClear())
{
move();
if(ballsPresent())
{
takeBall();
}
}
}
private void endUpFacingEast()
{
turnLeft();
move();
turnLeft();
}
private void endUpFacingWest()
{
turnRight();
move();
turnRight();
}
}