Maze Input Notes
Although the method to read in a text file and produce a corresponding Maze object is not very flashy, it is a necessary step towards getting your program gully functional. Since it's not the primary focus of the assignment, I don't really want you spending a lot of time on it. Therefore I make the following suggestions. These are not the only way to structure your code, but they will work as well as any other approach.
- Read the input file one line at a time.
- Since you don't know in advance how many lines there will be, you can't allocate the Maze grid right away. And if you're reading from the standard input, then reading through the input twice isn't an option. So store each line of the input as you read it in an ArrayList<String>, so that you can process it at leisure once you have all the data. (Note that an ArrayList is very similar to a LinkedList except that it uses an array as the underlying storage. However, you can add elements one at a time and the storage will automatically resize.)
- Once you have all the lines read in you will be able to see its dimensions, so you can allocate a grid of the proper size. Loop through the stored lines one at a time, character by character, and set the contents of the corresponding maze location based on whatever is in the input.