Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Scanner; import java.io . FileNotFoundException; public class MazeGame { / / Constants for array indices private static final int ROW = 0 ; private
import java.util.Scanner;
import java.ioFileNotFoundException;
public class MazeGame
Constants for array indices
private static final int ROW ;
private static final int COL ;
Fields
private final int HEIGHT ;
private final int WIDTH ;
private final int playerInput;
private final boolean blocked;
private final boolean visited;
private final int player;
private final int goal;
private final int start;
Constructors
public MazeGameScanner scanner throws FileNotFoundException
this.playerInput scanner.nextInt;
Call loadMaze here
public MazeGameString mazeFile throws FileNotFoundException
thisnew ScannerSystemin; Assume reading from keyboard
Getters and Setters
public int getPlayerInput
return playerInput;
public int getPlayerRow
return playerROW;
public void setPlayerRowint row
if row && row HEIGHT
playerROW row;
public int getPlayerCol
return playerCOL;
public void setPlayerColint col
if col && col WIDTH
playerCOL col;
public int getGoalRow
return goalROW;
public void setGoalRowint row
if row && row HEIGHT
goalROW row;
public int getGoalCol
return goalCOL;
public void setGoalColint col
if col && col WIDTH
goalCOL col;
Other methods not fully implemented
private boolean copyTwoDimBoolArrayboolean array
Implementation of copying a twodimensional boolean array
Left as an exercise for you
return null;
private void printMaze
Implementation of printing the maze
Left as an exercise for you
private void loadMazeString mazeFile throws FileNotFoundException
Implementation of loading maze from file
Left as an exercise for you
private void prompt
printMaze;
System.out.printEnter your move up down, left, right, or q to quit: ;
private boolean playerAtGoal
return playerROW goalROW && playerCOL goalCOL;
private boolean validint row, int col
return row && row HEIGHT && col && col WIDTH && blockedrowcol;
private void visitint row, int col
visitedrowcol true;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started