Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public CircuitBoard(String filename) throws FileNotFoundException
- {
- Scanner fileScan;
- try
- {
- fileScan = new Scanner(new File(filename));
- ROWS = fileScan.nextInt(); //replace with initialization statements using values from file
- COLS = fileScan.nextInt();
- String nextChar;
- board = new char[ROWS][COLS];
- int currentCol = 0;
- int currentRow = 0;
- for(int i = 0; i < ROWS - 1; i++)
- {
- for(int j = 0; j < COLS - 1; j++)
- {
- nextChar = fileScan.next();
- board[i][j] = nextChar.charAt(0);
- if(nextChar.charAt(0) == START)
- {
- startingPoint = new Point(i,j);
- }
- else if(nextChar.charAt(0) == END)
- {
- endingPoint = new Point(i,j);
- }
- }
- }
- }
- catch (FileNotFoundException FNFE)
- {
- throw new FileNotFoundException("CircuitBoard-CircuitBoard");
- }
- catch (InvalidFileFormatException IFFE)
- {
- throw new InvalidFileFormatException("CircuitBoard-CircuitBoard");
- }
- //TODO: parse the given file to populate the char[][]
- // throw FileNotFoundException if Scanner cannot read the file
- // throw InvalidFileFormatException if any formatting or parsing issues are encountered
- fileScan.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement