Question: complete the makeMove method in the following code package maze; import java.io . FileNotFoundException; import java.util.Scanner; public class MazeGame { public final static int HEIGHT

complete the makeMove method in the following code package maze;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class MazeGame {
public final static int HEIGHT =19;
public final static int WIDTH =39;
private final static int COL =1;
private final static int ROW =0;
private Scanner playerInput;
private boolean[][] blocked;
private boolean[][] visited;
private int[] player;
private int[] goal;
private int[] start;
public MazeGame(String mazeFile, Scanner playerInput) throws FileNotFoundException {
this.playerInput = playerInput;
loadMaze(mazeFile);
}
public MazeGame(String mazeFile) throws FileNotFoundException {
this(mazeFile, new Scanner(System.in));
}
public void playGame(){
}
public void printMaze(){
for (int row =0; row < HEIGHT; row++){
for (int col =0; col < WIDTH; col++){
if (row == getPlayerRow() && col == getPlayerCol()){
System.out.print("P");
} else if (row == getGoalRow() && col == getGoalCol()){
System.out.print("G");
} else if (blocked[row][col]){
System.out.print("#");
} else {
System.out.print(".");
}
}
System.out.println();
}
}
public int getPlayerRow(){
return player[ROW];
}
public int getPlayerCol(){
return player[COL];
}
public int getGoalRow(){
return goal[ROW];
}
public int getGoalCol(){
return goal[COL];
}
public int getStartRow(){
return start[ROW];
}
public int getStartCol(){
return start[COL];
}
public boolean[][] getBlocked(){
return copyTwoDimBoolArray(blocked);
}
public boolean[][] getVisited(){
return copyTwoDimBoolArray(visited);
}
public Scanner getPlayerInput(){
return this.getPlayerInput();
}
public void setPlayerRow(int row){
if (row >=0 && row < HEIGHT){
player[ROW]= row;
}
}
public void setPlayerCol(int col){
if (col >=0 && col < WIDTH){
player[COL]= col;
}
}
public void setGoalRow(int row){
if (row >=0 && row < HEIGHT){
goal[ROW]= row;
}
}
public void setGoalCol(int col){
if (col >=0 && col < WIDTH){
goal[COL]= col;
}
}
public void setStartRow(int row){
if (row >=0 && row < HEIGHT){
start[ROW]= row;
}
}
public void setStartCol(int col){
if (col >=0 && col < WIDTH){
this.start[COL]= col;
}
}
public void setBlocked(boolean[][] blocked){
blocked = copyTwoDimBoolArray(blocked);
}
public void setVisited(boolean[][] visited){
visited = copyTwoDimBoolArray(visited);
}
public void setPlayerInput(Scanner playerInput){
}
private boolean[][] copyTwoDimBoolArray(boolean[][] arrayToCopy){
int rows = arrayToCopy.length;
int cols = arrayToCopy[0].length;
boolean[][] copy = new boolean[rows][cols];
for (int i =0; i < rows; i++){
for (int j =0; j < cols; j++){
copy[i][j]= arrayToCopy[i][j];
}
}
return copy;
}
private void prompt(){
printMaze();
System.out.print("Enter your move (up, down, left, right, or q to quit): ");
}
private boolean playerAtGoal(){
return player[ROW]== goal[ROW] && player[COL]== goal[COL];
}
private boolean valid(int row, int col){
return row >=0 && row < HEIGHT && col >=0 && col < WIDTH && !blocked[row][col];
}
private void visit(int row, int col){
visited[row][col]= true;
}
private void loadMaze(String mazeFile){
}
private boolean makeMove(String move){
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!