Labyrinth
A labyrinth game assignment
host.labyrinth.Tile Class Reference

This class is the representation of the board's tile. More...

Package Functions

Constructors
 Tile (int row, int col, boolean up, boolean down, boolean left, boolean right)
 The main constructor of the Tile constructed from (row,column) More...
 
 Tile (int id, boolean up, boolean down, boolean left, boolean right)
 The main constructor of the Tile constructed from tileId. More...
 
 Tile (Tile t)
 A deep copy constructor. More...
 
Supply's main application interface
Position position ()
 
Position position (int row, int col)
 Set the position of the tile from a (row, column) pair. More...
 
Position position (int tileId)
 Set the position of the tile from a tileId. More...
 
void setWall (int direction)
 Sets the tile's wall in the requested direction. More...
 
void clearWall (int direction)
 Clears the tile's wall in the requested direction. More...
 
boolean hasWall (int direction)
 Checks if the tile has wall in the requested direction. More...
 
int hasWalls ()
 Checks if the tile has walls and return the number of them. More...
 
int hasSupply (Supply[] supplies)
 Utility to check if the tile has a supply. More...
 
void pickSupply (Supply[] supplies, int supplyId)
 Utility to find a supply in the supplies array and removes it. More...
 
Accessor/Mutator interface
Note
Please consider not to use mutator interface. Its the abstraction killer :( We have added a bit of logic however, in order to make it a bit more safe.
int getTileId ()
 
int getX ()
 
int getY ()
 
boolean getUp ()
 
boolean getDown ()
 
boolean getLeft ()
 
boolean getRight ()
 
void setTileId (int tileId)
 
void setX (int x)
 
void setY (int y)
 
void setUp (boolean up)
 
void setDown (boolean down)
 
void setRight (boolean right)
 
void setLeft (boolean left)
 

Private Attributes

Class data
int tileId
 The unique identifier of the tile. More...
 
int x
 The x coordinate(column) of the tile as if the board lies in the 1st quadrant. More...
 
int y
 The y coordinate(row) of the tile as if the board lies in the 1st quadrant. More...
 
boolean up
 Indicator of a wall in the north side of the tile. More...
 
boolean down
 Indicator of a wall in the south side of the tile. More...
 
boolean left
 Indicator of a wall in the left side of the tile. More...
 
boolean right
 Indicator of a wall in the right side of the tile. More...
 

Detailed Description

This class is the representation of the board's tile.

Tiles are arranged on the board in square shape and they're identified by an ID. This ID is the linear combination of x and y coordinate of the tile.

Definition at line 22 of file Tile.java.

Constructor & Destructor Documentation

◆ Tile() [1/3]

host.labyrinth.Tile.Tile ( int  row,
int  col,
boolean  up,
boolean  down,
boolean  left,
boolean  right 
)
package

The main constructor of the Tile constructed from (row,column)

Parameters
rowThe row coordinate to place the Tile
colThe column coordinate to place the Tile
upThe existence of wall north of the tile
downThe existence of wall south of the tile
leftThe existence of wall left of the tile
rightThe existence of wall right of the tile

Definition at line 37 of file Tile.java.

◆ Tile() [2/3]

host.labyrinth.Tile.Tile ( int  id,
boolean  up,
boolean  down,
boolean  left,
boolean  right 
)
package

The main constructor of the Tile constructed from tileId.

Parameters
idThe tileId to place the Tile
upThe existence of wall north of the tile
downThe existence of wall south of the tile
leftThe existence of wall left of the tile
rightThe existence of wall right of the tile

Definition at line 61 of file Tile.java.

◆ Tile() [3/3]

host.labyrinth.Tile.Tile ( Tile  t)
package

A deep copy constructor.

Definition at line 78 of file Tile.java.

Member Function Documentation

◆ clearWall()

void host.labyrinth.Tile.clearWall ( int  direction)
package

Clears the tile's wall in the requested direction.

Parameters
directionThe direction for the wall

Definition at line 155 of file Tile.java.

◆ getDown()

boolean host.labyrinth.Tile.getDown ( )
package

Definition at line 222 of file Tile.java.

◆ getLeft()

boolean host.labyrinth.Tile.getLeft ( )
package

Definition at line 223 of file Tile.java.

◆ getRight()

boolean host.labyrinth.Tile.getRight ( )
package

Definition at line 224 of file Tile.java.

◆ getTileId()

int host.labyrinth.Tile.getTileId ( )
package

Definition at line 218 of file Tile.java.

◆ getUp()

boolean host.labyrinth.Tile.getUp ( )
package

Definition at line 221 of file Tile.java.

◆ getX()

int host.labyrinth.Tile.getX ( )
package

Definition at line 219 of file Tile.java.

◆ getY()

int host.labyrinth.Tile.getY ( )
package

Definition at line 220 of file Tile.java.

◆ hasSupply()

int host.labyrinth.Tile.hasSupply ( Supply[]  supplies)
package

Utility to check if the tile has a supply.

Parameters
suppliesReference to supply array to check.
Returns
Const.noSupply if there is no supply or the supplyId if succeed.

Definition at line 192 of file Tile.java.

◆ hasWall()

boolean host.labyrinth.Tile.hasWall ( int  direction)
package

Checks if the tile has wall in the requested direction.

Parameters
directionThe direction to check
Returns
True if there is a wall

Definition at line 169 of file Tile.java.

◆ hasWalls()

int host.labyrinth.Tile.hasWalls ( )
package

Checks if the tile has walls and return the number of them.

Returns
The number of walls

Definition at line 183 of file Tile.java.

◆ pickSupply()

void host.labyrinth.Tile.pickSupply ( Supply[]  supplies,
int  supplyId 
)
package

Utility to find a supply in the supplies array and removes it.

Parameters
suppliesReference to supply array to check
supplyIdThe supplyId to search.

Definition at line 204 of file Tile.java.

◆ position() [1/3]

Position host.labyrinth.Tile.position ( )
package
Returns
the position of the tile as a Position object
See also
Position

Definition at line 97 of file Tile.java.

◆ position() [2/3]

Position host.labyrinth.Tile.position ( int  row,
int  col 
)
package

Set the position of the tile from a (row, column) pair.

Parameters
rowThe row coordinate of the tile
colThe column coordinate of the tile
Returns
the position of the supply as a Position object
Note
This function also returns the supplyId to help in chained expressions.
See also
Position

Definition at line 107 of file Tile.java.

◆ position() [3/3]

Position host.labyrinth.Tile.position ( int  tileId)
package

Set the position of the tile from a tileId.

Parameters
tileIdThe tileId position
Returns
The position of the supply as Position object
Note
This function also returns the supplyId to help in chained expressions.
See also
Position

Definition at line 126 of file Tile.java.

◆ setDown()

void host.labyrinth.Tile.setDown ( boolean  down)
package

Definition at line 244 of file Tile.java.

◆ setLeft()

void host.labyrinth.Tile.setLeft ( boolean  left)
package

Definition at line 246 of file Tile.java.

◆ setRight()

void host.labyrinth.Tile.setRight ( boolean  right)
package

Definition at line 245 of file Tile.java.

◆ setTileId()

void host.labyrinth.Tile.setTileId ( int  tileId)
package

Definition at line 226 of file Tile.java.

◆ setUp()

void host.labyrinth.Tile.setUp ( boolean  up)
package

Definition at line 243 of file Tile.java.

◆ setWall()

void host.labyrinth.Tile.setWall ( int  direction)
package

Sets the tile's wall in the requested direction.

Parameters
directionThe direction for the wall.

Definition at line 142 of file Tile.java.

◆ setX()

void host.labyrinth.Tile.setX ( int  x)
package

Definition at line 233 of file Tile.java.

◆ setY()

void host.labyrinth.Tile.setY ( int  y)
package

Definition at line 238 of file Tile.java.

Member Data Documentation

◆ down

boolean host.labyrinth.Tile.down
private

Indicator of a wall in the south side of the tile.

Definition at line 258 of file Tile.java.

◆ left

boolean host.labyrinth.Tile.left
private

Indicator of a wall in the left side of the tile.

Definition at line 259 of file Tile.java.

◆ right

boolean host.labyrinth.Tile.right
private

Indicator of a wall in the right side of the tile.

Definition at line 260 of file Tile.java.

◆ tileId

int host.labyrinth.Tile.tileId
private

The unique identifier of the tile.

This is the linear combination of x and y coordinates of the tile

Definition at line 251 of file Tile.java.

◆ up

boolean host.labyrinth.Tile.up
private

Indicator of a wall in the north side of the tile.

Definition at line 257 of file Tile.java.

◆ x

int host.labyrinth.Tile.x
private

The x coordinate(column) of the tile as if the board lies in the 1st quadrant.

Definition at line 255 of file Tile.java.

◆ y

int host.labyrinth.Tile.y
private

The y coordinate(row) of the tile as if the board lies in the 1st quadrant.

Definition at line 256 of file Tile.java.


The documentation for this class was generated from the following file: