import java.util.Random; // Student version: // Part 1: Movement not implemented // Part 2: Chase not implemented public class Chase { public static final int SIZE = 4; public static final char PLAYER = 'P'; public static final char MONSTER = 'M'; public static final char EMPTY = ' '; private char maze[][]; private int mRow; private int mColumn; private int dMRow; private int dMColumn; public Chase () { int r; int c; int temp; Random aGenerator = new Random(); maze = new char[SIZE][SIZE]; for (r = 0; r < SIZE; r++) for (c = 0; c < SIZE; c++) maze[r][c] = EMPTY; mRow = aGenerator.nextInt(SIZE); mColumn = aGenerator.nextInt(SIZE); maze[mRow][mColumn] = MONSTER; dMRow = mRow; dMColumn = mColumn; } public void display () { int r; int c; System.out.println(" 0 1 2 3"); for (r = 0; r < SIZE; r++) { System.out.println(" - - - -"); System.out.print(r + " "); for (c = 0 ; c < SIZE; c++) { System.out.print("|" + maze[r][c]); } System.out.println("|"); } System.out.println(" - - - -"); } // Part I: Given that the source and destination row,column // known move the monster from it's current to destination // location. public void move () { } // Part II: Determine destination: updated the dMRow, dMColumn values so // it chases the player public void determineDestination(int pRow, int pColumn) { } public void placePlayer (int r, int c) { maze[r][c] = PLAYER; } }