de.java_chess.javaChess.position
Class PositionImpl
java.lang.Object
|
+--de.java_chess.javaChess.position.PositionImpl
- public class PositionImpl
- extends java.lang.Object
- implements Position
This class implements the functionality to store the position
of a chess piece.
Method Summary |
boolean |
equals(Position pos)
Test if 2 positions are equal. |
int |
getLineIndex()
Get the line index of this postion (0-7). |
int |
getRowIndex()
Get the row index of this position (0-7). |
int |
getSquareIndex()
Get the square index of this position (0-63). |
void |
setSquareIndex(int squareIndex)
Set the square index of this position. |
java.lang.String |
toSquareName()
Convert this position to a square name (like 'a4'). |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
PositionImpl
public PositionImpl(int squareIndex)
getSquareIndex
public final int getSquareIndex()
- Get the square index of this position (0-63).
- Specified by:
- getSquareIndex in interface Position
- Returns:
- The square index of this position.
setSquareIndex
public final void setSquareIndex(int squareIndex)
- Set the square index of this position.
- Specified by:
- setSquareIndex in interface Position
- Parameters:
squareIndex
- The new square index of this position.
getRowIndex
public final int getRowIndex()
- Get the row index of this position (0-7).
- Specified by:
- getRowIndex in interface Position
- Returns:
- The row index of this position.
getLineIndex
public final int getLineIndex()
- Get the line index of this postion (0-7).
- Specified by:
- getLineIndex in interface Position
- Returns:
- The line index of this position.
toSquareName
public final java.lang.String toSquareName()
- Convert this position to a square name (like 'a4').
- Specified by:
- toSquareName in interface Position
- Returns:
- The suare name of this position.
equals
public final boolean equals(Position pos)
- Test if 2 positions are equal.
- Specified by:
- equals in interface Position
- Parameters:
Another
- position.- Returns:
- true, if the positions are equal, false otherwise.