Labyrinth
A labyrinth game assignment
|
Go to the documentation of this file.
13 package host.labyrinth;
39 assert (row >= 0 && row<
Session.
boardSize) :
"Row coordinate must be in the range [0, Session.boardSize)";
40 assert (col >= 0 && col<
Session.
boardSize) :
"Column coordinate must be in the range [0, Session.boardSize)";
64 :
"TileId must be in the range of [0, Session.boardSize^2)";
109 assert (row >= 0 && row<
Session.
boardSize) :
"Row coordinate must be in the range [0, Session.boardSize)";
110 assert (col >= 0 && col<
Session.
boardSize) :
"Column coordinate must be in the range [0, Session.boardSize)";
129 :
"TileId must be in the range of [0, Session.boardSize^2)";
134 this.tileId = p.
getId();
194 if (s.position().getId() ==
position().getId())
195 return s.getSupplyId();
206 if (s.getSupplyId() == supplyId)
228 :
"TileId must be in the range of [0, Session.boardSize^2)";
234 assert (
x >= 0 &&
x<
Session.
boardSize) :
"X(column) coordinate must be in the range [0, Session.boardSize)";
239 assert (
y >= 0 &&
y<
Session.
boardSize) :
"Y(row) coordinate must be in the range [0, Session.boardSize)";
void setRight(boolean right)
static int toCol(int id)
Takes Id coordinate and return the corresponding column coordinate.
static final int LEFT
West direction.
Class to hold constant values for entire application.
void pickSupply(Supply[] supplies, int supplyId)
Utility to find a supply in the supplies array and removes it.
int y
The y coordinate(row) of the tile as if the board lies in the 1st quadrant.
Position position(int row, int col)
Set the position of the tile from a (row, column) pair.
boolean hasWall(int direction)
Checks if the tile has wall in the requested direction.
int getRow()
Read access to virtual row coordinate.
This class is the representation of the supplies in the game.
Application wide object to hold settings like values for the session.
Position position(int tileId)
Set the position of the tile from a tileId.
static final int DOWN
South direction.
int hasSupply(Supply[] supplies)
Utility to check if the tile has a supply.
static final int RIGHT
East direction.
void clearWall(int direction)
Clears the tile's wall in the requested direction.
int tileId
The unique identifier of the tile.
int hasWalls()
Checks if the tile has walls and return the number of them.
static final int UP
North direction.
Tile(int id, boolean up, boolean down, boolean left, boolean right)
The main constructor of the Tile constructed from tileId.
This class is the representation of the board's tile.
static int boardSize
Default board's size (if no one set it via command line)
static int toRow(int id)
Takes Id coordinate and return the corresponding row coordinate.
void setWall(int direction)
Sets the tile's wall in the requested direction.
void setLeft(boolean left)
Tile(int row, int col, boolean up, boolean down, boolean left, boolean right)
The main constructor of the Tile constructed from (row,column)
An Application wide board position implementation holding just the id coordinate.
boolean down
Indicator of a wall in the south side of the tile.
boolean left
Indicator of a wall in the left side of the tile.
void setDown(boolean down)
boolean right
Indicator of a wall in the right side of the tile.
Tile(Tile t)
A deep copy constructor.
Helper C++-like enumerator class to hold direction.
int getCol()
Read access to virtual column coordinate.
static final int noSupply
Number to indicate the absent of supply.
int getId()
Read access to id coordinate.
boolean up
Indicator of a wall in the north side of the tile.
int x
The x coordinate(column) of the tile as if the board lies in the 1st quadrant.
void setTileId(int tileId)
static int toID(int row, int col)
Takes row and column coordinates and return the calculated Id coordinate.