
public class MazeController {
	private Maze myMaze;
	public MazeController(Maze aMaze) {
		myMaze = aMaze;
	}
	public MazeController() {
		this(new Maze(10, 10));
	}
	void execute(String command) throws Exception {
		int row = myMaze.getPlayerRow();
		int col = myMaze.getPlayerCol();
		int moves = myMaze.getPlayerMoves();
		int maxRows = myMaze.getMAX_ROW();
		int maxCols = myMaze.getMAX_COL();
		if (command.equalsIgnoreCase("North")) {
			row = (row == 0)?(maxRows - 1):(row - 1);
			myMaze.setPlayerRow(row);
			myMaze.setPlayerMoves(++moves);
		} else if (command.equalsIgnoreCase("West")) {
			col = (col == 0)?(maxCols - 1):(col - 1);
			myMaze.setPlayerCol(col);
			myMaze.setPlayerMoves(++moves);
		} else if (command.equalsIgnoreCase("East")) {
			col = (col + 1) % maxCols;
			myMaze.setPlayerCol(col);
			myMaze.setPlayerMoves(++moves);
		} else if (command.equalsIgnoreCase("South")) {
			row = (row + 1)% maxRows;
			myMaze.setPlayerRow(row);
			myMaze.setPlayerMoves(++moves);
		} else if (command.equalsIgnoreCase("Reset")) {
			myMaze.setPlayerCol(0);
			myMaze.setPlayerRow(0);
			myMaze.setPlayerMoves(0);
			myMaze.setExitCol((int)(Math.random() * maxCols));
			myMaze.setExitRow((int)(Math.random() * maxRows));
			
			System.out.println("exit = " + myMaze.getExitRow() + ", " + myMaze.getExitCol());
		} else {
			throw new Exception("Unrecognized command: " + command);
		}
	}
}
