I am trying to create an array that contains several different things, so that I can display a sort of maze in the command line. I am trying to use '*'
as the walls, and ' '
as empty spaces, but I would also like to add references to different objects, such as piles of gold, and little traps that are represented by characters like 'g' for gold, and 't' for trap.
All of the objects in the maze are going to be subclasses of a MazeObject class. So my question is whether I make the array out of chars, and how would I put object instances into the array, or should I make it a MazeObject array, but how do I include the '*'
as walls, and ' '
as spaces. Or is there some way to have a MazeObject array of chars?
MazeObject maze[][] = new MazeObject[rows][columns]
or
char maze[][] = new char[rows][columns]
or polymorphism?
MazeObject[][] maze = new char[rows][columns]