|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.almacha.achamaze.Maze
public class Maze
This class represents a maze.
| Field Summary | |
|---|---|
private int |
height
|
private Cell[][] |
maze
|
private int |
nextPlayerId
|
private java.util.LinkedList<Player> |
players
|
private int |
startColumn
|
private int |
startLine
|
private int |
width
|
| Constructor Summary | |
|---|---|
Maze(int height,
int width)
This constructor creates a new maze. |
|
| Method Summary | |
|---|---|
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. |
private Cell |
getCell(int i,
int j)
|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Cell[][] maze
private int height
private int width
private java.util.LinkedList<Player> players
private int nextPlayerId
private int startLine
private int startColumn
| Constructor Detail |
|---|
public Maze(int height,
int width)
throws AchaMazeException
height - the number of lines, must be >= 1width - the number of columns, must be >= 1
AchaMazeException - thrown if width or height is invalid| Method Detail |
|---|
public boolean cellExists(int i,
int j)
i - the line number of the cellj - the column number of the cell
public void checkCellExists(int i,
int j)
throws CellDoesNotExistException
i - the line number of the cellj - the column number of the cell
CellDoesNotExistException - in case the cell does not exist
private Cell getCell(int i,
int j)
throws CellDoesNotExistException
CellDoesNotExistException
public 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 wall
CellDoesNotExistException
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 cell
CellDoesNotExistException - 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 - column
CellDoesNotExistExceptionpublic 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 go
CellDoesNotExistException - in case (i,j) is not a cell in the maze
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||