Karel The Robot - rightIsBlocked() is undefined for the type

52 Views Asked by At

I am a AP Comp Sci student and we have been given an assignment to code karel the robot to climb over a few hurdles I put the code:

private void ascendHurdle(){
        r.turnLeft();
        while (rightIsBlocked()) {
            r.move();
        }
        r.turnRight();  
    }

it says that rightIsBlocked is undefined for the type however on the documentation it says that it is a valid command https://www.cs.mtsu.edu/~untch/karel/selection.html <--- the documentation I used Please help

1

There are 1 best solutions below

1
zmehall On

I'd assume that r is the object that represents your robot. Although it's not very clear based on the documentation, rightIsBlocked() is probably not static, so you'd have to use r.rightIsBlocked() (because r is your instance of the robot's class).

I could be wrong, but hopefully this helps.