Labyrinth
A labyrinth game assignment
net.hoo2.auth.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 row-column naming convention.

Definition at line 77 of file Common.java.

Constructor & Destructor Documentation

◆ Position() [1/3]

net.hoo2.auth.labyrinth.Position.Position ( int  row,
int  col 
)
package

Basic constructor from row-column coordinates.

Parameters
rowThe row coordinate
colThe column coordinate

Definition at line 84 of file Common.java.

◆ Position() [2/3]

net.hoo2.auth.labyrinth.Position.Position ( int  tileId)
package

Basic constructor from Id.

Parameters
tileIdThe id of tile

Definition at line 92 of file Common.java.

◆ Position() [3/3]

net.hoo2.auth.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 105 of file Common.java.

Member Function Documentation

◆ getCol()

int net.hoo2.auth.labyrinth.Position.getCol ( )
package

Read access to virtual column coordinate.

Definition at line 117 of file Common.java.

◆ getId()

int net.hoo2.auth.labyrinth.Position.getId ( )
package

Read access to id coordinate.

Definition at line 118 of file Common.java.

◆ getRow()

int net.hoo2.auth.labyrinth.Position.getRow ( )
package

Read access to virtual row coordinate.

Definition at line 116 of file Common.java.

◆ toCol()

static int net.hoo2.auth.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 146 of file Common.java.

◆ toID()

static int net.hoo2.auth.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 129 of file Common.java.

◆ toRow()

static int net.hoo2.auth.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 138 of file Common.java.

Member Data Documentation

◆ id

int net.hoo2.auth.labyrinth.Position.id
private

The id coordinate of the constructed Position object.

Definition at line 153 of file Common.java.


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