When I try to compile this code I get an error saying else without if. I believe that I have all of the braces in the right place. I also get other errors to that are in the picture that I have attached but I just believe they are there because of the can't use else without if error.
Problem code:
public static boolean goNorth(){
boolean success;
if(maze[currCol]currRow - 1] == CLEAR){
maze[currCol][startRow -1] = PATH;
currRow--;
success = goNorth();
if(!success){
success = goWest();
if(!success){
success = goEast();
if(!success){
maze[currCol][currRow] = VISITED;
currRow++;
}
}
}
return success;
} else {
return false;
}
}
public static boolean goWest(){
boolean success;
if(maze[currCol - 1]currRow] == CLEAR){
maze[currCol - 1][startRow] = PATH;
currRow--;
success = goWest();
if(!success){
success = goSouth();
if(!success){
success = goNorth();
if(!success){
maze[currCol][currRow] = VISITED;
currCol++;
}
}
}
return success;
} else {
return false;
}
}
public static boolean goEast(){
boolean success;
if(maze[currCol + 1]currRow] == CLEAR){
maze[currCol + 1][startRow] = PATH;
currRow--;
success = goEast();
if(!success){
success = goNorth();
if(!success){
success = goSouth();
if(!success){
maze[currCol][currRow] = VISITED;
currCol--;
}
}
}
return success;
} else {
return false;
}
}
public static boolean goSouth(){
boolean success;
if(maze[currCol]currRow + 1] == CLEAR){
maze[currCol][startRow + 1] = PATH;
currRow--;
success = goSouth();
if(!success){
success = goEast();
if(!success){
success = goWest();
if(!success){
maze[currCol][currRow] = VISITED;
currRow--;
}
}
}
return success;
} else {
return false;
}
}
Error: