Class Position

java.lang.Object
javachess.model.Position

public class Position extends Object
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 Details

    • Position

      public Position(int x, int y)
    • Position

      public Position(String part)
      Constructs a Position object from a string representation.
      Parameters:
      part - the string representation of the position (e.g., "a1", "h8")
  • Method Details

    • equals

      public boolean equals(Position position)
    • set

      public void set(int x, int y)
    • add

      public void add(int dx, int dy)
    • add

      public void add(Position position)
    • add

      public void add(Directions directions)
    • getX

      public int getX()
    • getY

      public int getY()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asPGN

      public String asPGN()
      Converts the position to a string representation in PGN format.
      Returns:
      the PGN representation of the position (e.g., "a1", "h8")