Question: I need help reading a board from a given file (Board.dat) using the given method template. public static String[][] ReadBoardFromFile(String fileName, Position startPosition, Position exitPosition)
I need help reading a board from a given file ("Board.dat") using the given method template.
public static String[][] ReadBoardFromFile(String fileName, Position startPosition, Position exitPosition)
the given board.dat file will look something like this:
- The data in the file will be separated by one space
- Assume that all data in the file is valid
- Clear and Start squares (no obstacles) will be marked with # in the file
- The first line of the file contains the dimensions of the board (rows and columns) e.g. 3 7
- The second line contains the Start square indexes (rowIndex, columnIndex)
- The third line contains the Exit square indexes (rowIndex, columnIndex)
- The rest of the lines represent the contents, including obstacles, of a row on the board
- Example of a Board size 5x5 data file:
5 5
2 2
4 3
# -5 # # #
# # # 0 #
# # # # #
# -3 # # -4
-10 # # # #
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
