Package javachess.model
Class Position
java.lang.Object
javachess.model.Position
Class representing a position on the chessboard.
The position is represented by x and y coordinates.
The coordinate (0, 0) corresponds to the top-left corner of the board.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Position
public Position(int x, int y) -
Position
Constructs a Position object from a string representation.- Parameters:
part- the string representation of the position (e.g., "a1", "h8")
-
-
Method Details
-
equals
-
set
public void set(int x, int y) -
add
public void add(int dx, int dy) -
add
-
add
-
getX
public int getX() -
getY
public int getY() -
equals
-
hashCode
public int hashCode() -
toString
-
asPGN
Converts the position to a string representation in PGN format.- Returns:
- the PGN representation of the position (e.g., "a1", "h8")
-