public class Maze
extends java.lang.Object
Constructor and Description |
---|
Maze(int height,
int width)
This constructor creates a new maze.
|
Modifier and Type | Method and Description |
---|---|
void |
addPlayer()
Adds a player in the maze.
|
boolean |
canMove(int i,
int j,
Direction d)
Tells whether it is possible to move in direction d from cell (i, j).
|
boolean |
cellExists(int i,
int j)
Returns whether the cell (i,j) exists in the maze.
|
void |
checkCellExists(int i,
int j)
Raises a CellDoesNotExistException if and only if cellExists(i, j) is false.
|
int |
getHeight()
Returns the height (number of lines) of the maze.
|
int |
getNumberOfPlayers()
This method returns the number of players in the maze.
|
Player |
getPlayer(int playerId) |
int |
getStartColumn()
Returns the current start position (column).
|
int |
getStartLine()
Returns the current start position (line).
|
int |
getWidth()
Returns the width (number of columns) of the maze.
|
boolean |
isFilled(int i,
int j)
Tells whether the cell (i,j) is filled.
|
boolean |
isWallUp(int i,
int j,
Direction wall)
This method returns whether a wall is up or not.
|
void |
resetPlayers()
Deletes all player in the maze.
|
void |
setFilled(int i,
int j,
boolean filled)
Sets whether a cell is filled or not.
|
void |
setStartPosition(int i,
int j)
Defines the position at which new players start in the maze.
|
void |
setWallIsUp(int i,
int j,
Direction wall,
boolean isUp)
This method sets whether a wall is there or not.
|
public Maze(int height, int width) throws AchaMazeException
height
- the number of lines, must be >= 1width
- the number of columns, must be >= 1AchaMazeException
- thrown if width or height is invalidpublic boolean cellExists(int i, int j)
i
- the line number of the cellj
- the column number of the cellpublic void checkCellExists(int i, int j) throws CellDoesNotExistException
i
- the line number of the cellj
- the column number of the cellCellDoesNotExistException
- in case the cell does not existpublic void setWallIsUp(int i, int j, Direction wall, boolean isUp) throws CellDoesNotExistException
i
- the line of the cell whose wall you want to modifyj
- the column of the cell whose wall you want to modifywall
- the wall of the cell you want to modify (North, Est, South or West)isUp
- whether you want to enable or disable this wallCellDoesNotExistException
public boolean isWallUp(int i, int j, Direction wall) throws CellDoesNotExistException
i
- the line of the cell whose wall you want to know if it is upj
- the column of the cell whose wall you want to know if it is upwall
- the wall of the cell you want to look at (North, Est, South or West)CellDoesNotExistException
- exception thrown if the required cell does not existpublic int getWidth()
public int getHeight()
public void setFilled(int i, int j, boolean filled) throws CellDoesNotExistException
i
- the line of the cellj
- the column of the cellfilled
- wheter the cell should be filled
(player cannot go on it) or empty (player can go on it)CellDoesNotExistException
public boolean isFilled(int i, int j) throws CellDoesNotExistException
i
- the line of the cellj
- the column of the cellCellDoesNotExistException
- in case (i,j) is not a cell in the mazepublic void addPlayer()
public void resetPlayers()
public int getNumberOfPlayers()
public Player getPlayer(int playerId)
public void setStartPosition(int i, int j) throws CellDoesNotExistException
i
- linej
- columnCellDoesNotExistException
public int getStartLine()
public int getStartColumn()
public boolean canMove(int i, int j, Direction d) throws CellDoesNotExistException
i
- line of the cellj
- column of the celld
- direction where we want to goCellDoesNotExistException
- in case (i,j) is not a cell in the maze