Currently I created a 2D array to represent a grid for a maze. My maze constructor is as follow:
public Maze(int rows, int columns)
{
this.rows = rows;
this.cols = columns;
curr = new Square[rows][columns];
}
with the following in my testing class:
Maze m = new Maze(4, 4);
However, when I am traversing through my maze, while debugging I have noticed that curr is initialized to be Square[4][] with no arguments for the columns. Does anyone have any idea what the problem may be here?
Edit: That is what I'm intending to do; I make curr = Square[rows][columns] yet when I check the value of curr while in the following loop, in the debugger tool curr has the value Square[4][] for whenever it steps into curr[i][j] in the loops.
for(int i = 0; i < maze.length; i++)
{
for(int j = 0; j < maze[i].length; j++)
{
/* Entrance */
if(maze[i][j] == start)
{
startX = j;
startY = i;
curr[i][j] = new Square(i, j, start, this);
}
/* Exit */
else if(maze[i][j] == end)
{
endX = j;
endY = i;
curr[i][j] = new Square(i, j, end, this);
}
/* Traversable Squares */
else if(maze[i][j] == traverse)
{
curr[i][j] = new Square(i, j, traverse, this);
}
/* Non-traversable Squares */
else
{
curr[i][j] = new Square(i, j, noTraverse, this);
}
}
}
