Im stuck on how i shlud set up my Maze class in order to get started with solving it recursively. The maze has values stored into a two dimensional array " char[][] maze" and from there im stuck. heres my codes so far:

public class Maze {
    char start;
    int startX;
    int startY;
    char end;
    int endX;
    int endY;

    char[][] maze;

    public Maze(char[][] maze) {
        this.maze = maze;

    }

    public void startPoint(){
        for (int i=0; i < maze.length; i++){
            for (int j=0; j < maze.length; j++){
                if (String.valueOf(maze[i][j]) == "s"){
                    start = maze[i][j];
                    startX = i;
                    startY = j;
                }
            }
        }   
    }

    public void endPoint(){
        for (int i=0; i < mazeArray.length; i++){
            for (int j=0; j < mazeArray.length; j++){
                if (String.valueOf(mazeArray[i][j]) == "e"){
                    end = mazeArray[i][j];
                    endX = i;
                    endY = j;
                }
            }
        }   
    }

    public void isWall(){
        for (int i=0; i < maze.length; i++){
            for (int j=0; j < maze.length; j++){
                if (String.valueOf(maze[i][j]) == "|"){
                    wall = maze[i][j];
                    wallX = i;
                    wallY = j;
                }
            }
        }   
    }

    public void isPath() {
        for (int i=0; i < maze.length; i++){
            for (int j=0; j < maze.length; j++){
                if (String.valueOf(maze[i][j]) == "."){
                    open = maze[i][j];
                    openX = i;
                    openY = j;
                }
            }
        }   
    }

    public void displayMaze() {
        for (int i=0; i < maze.length; i++){
            for (int j=0; j < maze.length; j++){
                System.out.print(maze[i][j]);
            }
        System.out.println();
        }
    }
}

I just need some help. Can u point me in a specific direction as to what i should add, erase, and solve as simple as possible using recursive methods. Thanks!

Can you describe the steps the code should take to solve the problem?
What is the program supposed to do?

Pretty much the program opens a txt file with a sample maze to be read into a 2d array which ive already done in my driver class. "s" - starting point, "e" - ending point, "|" - wall, "." open path. Im supposed to find a solution to the maze using recursion from the starting point "s" to "e" in any manner, no shortest solution is required just a solution. Also the solution should be a set of directions from the users point of view (left, right, down, up).

Work on the program's requirements one by one.
How is the program going to read in the file with the sample maze and save its contents?

Ive already done that portion separately just didnt show it in the code. the first two lines of that text file are #, the first being # of rows and # of columns which i create a char 2d array from. I used readline() for the first line of the file then the second line of the file. Ive stored them into an array already. Now i have a visual representation of the maze able to print using my displayMaze() method. Now i just need to figure out how to solve with recursion

Work through how you'd solve it with any method. How does it find the Starting s location, what would the program need to look at? How would it determine where it can move to? When and how can it make a move?
What part of the searchig logic can be used recursively?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.