Class Position

java.lang.Object
  extended by Position

public class Position
extends java.lang.Object

The class Position represents a position on the field.


Field Summary
static java.lang.String ERR_MOVE_POS_FORMAT
          error message: move position
static java.lang.String REGEX_BOARDLIKE_FORMAT
          The format of a position as a String
 int x
          The x-coordinate in the Cartesian coordinate system
 int y
          The y-coordinate in the Cartesian coordinate system
 
Constructor Summary
Position(int x, int y)
          Constructor for the class Position.
Position(java.lang.String position)
          Constructor for the class Position.
 
Method Summary
 java.lang.String toString()
          Return a String representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REGEX_BOARDLIKE_FORMAT

public static final java.lang.String REGEX_BOARDLIKE_FORMAT
The format of a position as a String

See Also:
Constant Field Values

ERR_MOVE_POS_FORMAT

public static final java.lang.String ERR_MOVE_POS_FORMAT
error message: move position

See Also:
Constant Field Values

x

public final int x
The x-coordinate in the Cartesian coordinate system


y

public final int y
The y-coordinate in the Cartesian coordinate system

Constructor Detail

Position

public Position(java.lang.String position)
Constructor for the class Position. It stores the position in decimal out of a String like "A10" or "D9".

Parameters:
position - the String with the position

Position

public Position(int x,
                int y)
Constructor for the class Position. It stores the position directly in the Cartesian coordinate system.

Parameters:
x - the x-coordinate in the Cartesian coordinate system
y - the y-coordinate in the Cartesian coordinate system
Method Detail

toString

public java.lang.String toString()
Return a String representation of the object. Convert coordinates from Cartesian to board-like (e.g. (0 | 0) to A1 )

Overrides:
toString in class java.lang.Object
Returns:
String