|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.almacha.achamaze.Player
public class Player
This class represents a player that is in the maze. You cannot create directly an object of this class, instead you have to use the addPlayer() method from the Maze class.
| Field Summary | |
|---|---|
private boolean |
inMaze
|
private Maze |
maze
|
private MazeSolvingAlgorithm |
mazeSolvingAlgorithm
|
private int |
playerId
|
private PlayerStateForMazeAlgo |
playerStateForMazeAlgo
|
private int |
positionColumn
|
private int |
positionLine
|
| Constructor Summary | |
|---|---|
Player(Maze maze,
int i)
|
|
| Method Summary | |
|---|---|
boolean |
canMove(Direction d)
Tells whether the player can move in direction d. |
void |
checkIsInMaze()
Throws PlayerNotInMazeException if player is not in maze. |
void |
exitMaze()
Get player out of the maze. |
MazeSolvingAlgorithm |
getMazeSolvingAlgorithm()
Returns the solving algorithm associated with the player. |
int |
getPlayerId()
Get player id. |
int |
getPositionColumn()
Returns the current position of the player. |
int |
getPositionLine()
Returns the current position of the player. |
PlayerStateForMazeAlgo |
getStateForMazeAlgo()
|
boolean |
isInMaze()
Tells whether the player is in the maze. |
void |
move(Direction direction)
Move in the requested direction. |
void |
setMazeSolvingAlgorithm(MazeSolvingAlgorithm mazeSolvingAlgorithm)
Associates a maze solving algorithm to that player. |
void |
setPosition(int i,
int j)
Sets the current position of the player. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private int playerId
private int positionLine
private int positionColumn
private Maze maze
private boolean inMaze
private PlayerStateForMazeAlgo playerStateForMazeAlgo
private MazeSolvingAlgorithm mazeSolvingAlgorithm
| Constructor Detail |
|---|
public Player(Maze maze,
int i)
| Method Detail |
|---|
public int getPositionColumn()
throws PlayerNotInMazeException
PlayerNotInMazeException
public int getPositionLine()
throws PlayerNotInMazeException
PlayerNotInMazeException
public void setPosition(int i,
int j)
throws CellDoesNotExistException
i - linej - column
CellDoesNotExistException - in case (i,j) does not existpublic void exitMaze()
public boolean canMove(Direction d)
d - direction where we want to know if we can move
public void move(Direction direction)
throws PlayerCannotMoveException
direction -
PlayerCannotMoveException - in case we cannot move in this directionpublic boolean isInMaze()
public void checkIsInMaze()
throws PlayerNotInMazeException
PlayerNotInMazeException - in case player is not in mazepublic int getPlayerId()
public PlayerStateForMazeAlgo getStateForMazeAlgo()
public MazeSolvingAlgorithm getMazeSolvingAlgorithm()
public void setMazeSolvingAlgorithm(MazeSolvingAlgorithm mazeSolvingAlgorithm)
throws AchaMazeException
mazeSolvingAlgorithm - a instance of maze solving algorithm
AchaMazeException - in case the algorithm is associated to another player
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||