public class BoardItem {
  int x;
  int y;

  public BoardItem(int x, int y) {
    this.x = x;
    this.y = y;
  }

  public int getX() {
    return x;
  }

  public void setX(int x) {
    this.x = x;
    if (this instanceof Player)
      System.out.println("Moved to " + x + " " + y);
  }

  public int getY() {
    return y;
  }

  public void setY(int y) {
    this.y = y;
    if (this instanceof Player)
      System.out.println("Moved to " + x + " " + y);
  }

  public boolean equals(Object obj) {
    if (obj instanceof BoardItem)
      return x == ((BoardItem) obj).getX() && y == ((BoardItem) obj).getY();
    return false;
  }

  public int distanceTo(BoardItem obj) {
    return Math.abs(getX() - obj.getX()) + Math.abs(getY() - obj.getY());
  }

  public boolean positionEquals(int x, int y) {
    return this.x == x && this.y == y;
  }
}
