public class Puzzle extends Object{ private char[][] puzzleGrid; /** * Load a puzzle from a puzzle file. If any errors occur * during the processing of the puzzle file, the appropriate * exceptions will be thrown. * * @param puzzleFile the name of the file containing the * puzzle to load * @throw PuzzleFileFormatException if puzzle file is invalid * @throw java.io.IOException * @throw java.io.FileNotFoundException */ public Puzzle( String puzzleFile ) throws PuzzleFileFormatException, java.io.IOException, java.io.FileNotFoundException{ Scanner file = new Scanner( puzzleFile ); puzzleGrid = new char [file.nextInt()][file.nextInt()]; for( int i = 0; i < puzzleGrid.length; i++){ String row = file.next(); for( int j = 0; j < puzzleGrid[i].length; j++){ puzzleGrid[i][j] = row.charAt(j); } } } /** * Replace the puzzle currently stored in this object with * the puzzle contained in the given file. If any error * occurs during the processing of the puzzle file, the * puzzle will be set to null and the appropriate exception * will be thrown. * * @param puzzleFile the name of the file containing the puzzle to load * @throw PuzzleFileFormatException if puzzle file is invalid * @throw java.io.FileNotFoundException * @throw java.io.IOException */ public void setPuzzle( String puzzleFile ) throws java.io.FileNotFoundException, java.io.IOException, PuzzleFileFormatException{ } /** * Print the puzzle contained in this object to standard output. */ public void print(){ for( int i = 0; i < puzzleGrid.length; i++){ System.out.println(); for( int j = 0; j < puzzleGrid[i].length; j++){ System.out.print(puzzleGrid[i][j]); } } }