Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is my Tile class below public abstract class Tile { public String symbol; public boolean passable; private Content tile; public Tile(String symbol, boolean passable){
This is my Tile class below
public abstract class Tile { public String symbol; public boolean passable; private Content tile; public Tile(String symbol, boolean passable){ this.symbol = symbol; this.passable = passable; } public Tile(String symbol, boolean passable, Content tile){ this.symbol = symbol; this.passable = passable; this.tile = tile; } public String getSymbol(){ if(tile != null){ return tile.getSymbol(); } else{ return symbol; } } public boolean isPassable(){ if(passable = true){ } return passable; }
}
Create a Gameboard class that will hold and manage a 2D array of tiles that will represent the game state To initialize the game board, data will be read in from a text file. The text file has the following format. The first row contains two integers that specify how many rows and columns are in the rectangular game board. The rest of the file gives the initial state of the game board. It has the same format as the output that we have been generating to this point: "Y" is the amulet, ""is the player, and so on. The Gameboard class, for this phase, only needs instance variable of type Tile00 Write a constructor that accepts a file name as a parameter (a String). Open that file, read the contents, and initialize your two dimensional array of tiles based on the file. It can be assumed that the file will be in the same folder as your code. Write a toString0 method that returns the game board as a multi-line String. The first line should give the current health of the player, and the remaining lines should show the board. See the examples below n test your class with TestPhase4.java. You should get the output shown below. Make sure the supplied test data files (phase4GameBoard1.txt and phase4GameBoard2.txt) are in the same folder as the rest of your files. Health: 100 #Ah@.TW #.h..h# Health: 100Step 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