/** * Maze.java * A class for loading and printing mazes from files. * * @author YOUR NAME AND YOUR PARTNER'S NAME */ public class Maze { private ArrayList> rowList; private int w; private int h; // OTHER INSTANCE VARIABLES IF YOU NEED THEM /** * Constructor for the Maze class */ public Maze() { rowList = new ArrayList>(); } /** * Load in a Maze from a given file * * @param fileName the name of the file containing the maze */ public void load(String fileName) { // Create a scanner for the given file Scanner scanner = null; try { scanner = new Scanner(new File(fileName)); } catch (FileNotFoundException e) { System.err.println(e); System.exit(1); } // First line of file is "w h" String[] lineParams = scanner.nextLine().split(" "); w = Integer.parseInt(lineParams[0]); h = Integer.parseInt(lineParams[1]); // YOUR CODE TO FINISH LOADING FILE HERE } /** * Print the Maze to System.out */ public void print() { // YOUR CODE HERE } // MORE METHODS AS YOU NEED THEM // This main program acts as a simple unit test for the // load-from-file and print-to-System.out Maze capabilities. public static void main(String[] args) { if (args.length != 1) { System.err.println("Usage: java Maze mazeFile"); System.exit(1); } Maze maze = new Maze(); maze.load(args[0]); maze.print(); } }