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

An Application wide board position implementation holding just the id coordinate. More...

Package Functions

 Position (int row, int col)
 Basic constructor from row-column coordinates. More...
 
 Position (int tileId)
 Basic constructor from Id. More...
 
 Position (int row, int col, int direction)
 Constructor from row-column coordinates and a direction. More...
 
non-static API
int getRow ()
 Read access to virtual row coordinate. More...
 
int getCol ()
 Read access to virtual column coordinate. More...
 
int getId ()
 Read access to id coordinate. More...
 

Static Package Functions

Static convention utilities
static int toID (int row, int col)
 Takes row and column coordinates and return the calculated Id coordinate. More...
 
static int toRow (int id)
 Takes Id coordinate and return the corresponding row coordinate. More...
 
static int toCol (int id)
 Takes Id coordinate and return the corresponding column coordinate. More...
 

Private Attributes

private data types
int id
 The id coordinate of the constructed Position object. More...
 

Detailed Description

An Application wide board position implementation holding just the id coordinate.

Position is a helper class to enable us cope with the redundant position data (id and coordinates). This class provide both static conversion functionalities between id and coordinates and data representation in the coordinates system. For clarity we adopt a tileId convention.

Definition at line 81 of file Common.java.

Constructor & Destructor Documentation

◆ Position() [1/3]

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

Basic constructor from row-column coordinates.

Parameters
rowThe row coordinate
colThe column coordinate

Definition at line 88 of file Common.java.

◆ Position() [2/3]

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

Basic constructor from Id.

Parameters
tileIdThe id of tile

Definition at line 96 of file Common.java.

◆ Position() [3/3]

host.labyrinth.Position.Position ( int  row,
int  col,
int  direction 
)
package

Constructor from row-column coordinates and a direction.

This constructor creates a position relative to coordinates.

Parameters
rowThe row coordinate
colThe column coordinate
directionThe direction

Definition at line 109 of file Common.java.

Member Function Documentation

◆ getCol()

int host.labyrinth.Position.getCol ( )
package

Read access to virtual column coordinate.

Definition at line 121 of file Common.java.

◆ getId()

int host.labyrinth.Position.getId ( )
package

Read access to id coordinate.

Definition at line 122 of file Common.java.

◆ getRow()

int host.labyrinth.Position.getRow ( )
package

Read access to virtual row coordinate.

Definition at line 120 of file Common.java.

◆ toCol()

static int host.labyrinth.Position.toCol ( int  id)
staticpackage

Takes Id coordinate and return the corresponding column coordinate.

Parameters
idThe id coordinate
Returns
The column coordinate

Definition at line 150 of file Common.java.

◆ toID()

static int host.labyrinth.Position.toID ( int  row,
int  col 
)
staticpackage

Takes row and column coordinates and return the calculated Id coordinate.

Parameters
rowThe row coordinate
colThe column coordinate
Returns
The converted value

Definition at line 133 of file Common.java.

◆ toRow()

static int host.labyrinth.Position.toRow ( int  id)
staticpackage

Takes Id coordinate and return the corresponding row coordinate.

Parameters
idThe id coordinate
Returns
The row coordinate

Definition at line 142 of file Common.java.

Member Data Documentation

◆ id

int host.labyrinth.Position.id
private

The id coordinate of the constructed Position object.

Definition at line 157 of file Common.java.


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