Hi!
I'm doing a project where a robot is in a "corridor" with 4 sides and 4 corners. The robot starts in the top right corner and could be facing either South or West (it could move in a clockwise or counterclockwise direction) and should go one lap around the corridor and end up in the same spot.

I have created a method where the robot checks in every corner if it should turn left or right (see below) but it is very clumpsy. Is there
any easier way to code this?

My instructions says: "When the robot is at the end of one corridor and is facing the wall, it is easy to find out if it is moving in a
clockwise or counterclockwise direction. If there is a wall on the robots left side the movement is clockwise and vice versa.

But I don't understand how it can check if there is a wall on the sides? I only know the "frontIsClear"-method.



public void checkIfClear() {

if (!robot.frontIsClear()) {
robot.turnLeft();
counter++;
}
if (!robot.frontIsClear()){
turnAround();
counter++;
}
}