The class Maze
instanciates an 2D boolean-Array with the method: generateMaze(int width, int height)
which has to be used in Walker
.
The method-call to create the boolean[][] happens at the main
of the Walker class
My aim is to call the boolean[ ][ ]-Array with walk(Maze maze),
the input for the method has to be the Maze-Object, not the actual boolean[ ][ ].
I do not understand how to call it, there has to be a way to call it with an object instance of an Maze-Object.
public final class Maze{
public static boolean[][] generateMaze(int width, int height) {
boolean[][] mazeArray = new boolean[width][height];
for( int x = 0; x < width; x++ ) {
mazeArray[x][0] = true;
}
for( int y = 0; y < height; y++ ) {
mazeArray[0][y] = true;
}
return mazeArray;
}
public boolean[][] getBooleanArray() {
return generateMaze(2,2);
}
}
public class Walker {
public static void main(String[] args) {
boolean[][] maze = Maze.generateMaze(2,2);
Walker walker = new Walker();
Maze mazeObj = new Maze();
walker.walk( mazeObj );
}
public void walk(Maze maze) {
// This call doesnt work. Why?
System.out.println( mazeObj.maze[0][0] );
}
}