package com.anttilip.chkm8.model;

public class Position {
    private final int x;
    private final int y;
    
    public Position(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
    
    public boolean onBoard() {
        return (this.x >= 0 && this.x < 8 && this.y >= 0 && this.y < 8);
    }
    
    public String toString() {
        String alphabets = "ABCDEFGH";
        return alphabets.charAt(this.x) + Integer.toString(y + 1);
    }
    
    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Position)) {
            return false;
        }
        Position other = (Position) o;
        
        return other.x == this.x && other.y == this.y;
    }
    
    @Override
    public int hashCode() {
        return 11 * this.x + this.y;
    }
    
    public static Position add(Position a, Position b) {
        return new Position(a.getX() + b.getX(), a.getY() + b.getY());
    }

}

@@ -71,19 +71,54 @@
 ate 
-final int x
+static final String BOARD_LETTERS = %22ABCDEFGH%22
 ;%0D%0A 
@@ -128,21 +128,35 @@
 private 
-f
 in
-al
+t x;%0D%0A    private
  int y;%0D
@@ -152,24 +152,26 @@
 ate int y;%0D%0A
+%0D%0A
     %0D%0A    pu
@@ -434,17 +434,32 @@
 his.x %3C 
-8
+Board.BOARD_SIZE
  && this
@@ -478,17 +478,32 @@
 his.y %3C 
-8
+Board.BOARD_SIZE
 );%0D%0A    
@@ -526,93 +526,397 @@
 lic 
-String toString() %7B%0D%0A        String alphabets = %22ABCDEFGH%22;%0D%0A        return alphabets
+Position add(int x, int y) %7B%0D%0A        this.x += x;%0D%0A        this.y += y;%0D%0A        return this;%0D%0A    %7D%0D%0A%0D%0A    public Position copy() %7B%0D%0A        return new Position(this.x, this.y);%0D%0A    %7D%0D%0A%0D%0A    public static Position add(Position a, Position b) %7B%0D%0A        return new Position(a.getX() + b.getX(), a.getY() + b.getY());%0D%0A    %7D%0D%0A%0D%0A    public String toString() %7B%0D%0A        return BOARD_LETTERS
 .cha
@@ -954,36 +954,32 @@
 y + 1);%0D%0A    %7D%0D%0A
-    
 %0D%0A    @Override%0D
@@ -1141,18 +1141,8 @@
 o;%0D%0A
-        %0D%0A
     
@@ -1196,28 +1196,24 @@
 .y;%0D%0A    %7D%0D%0A
-    
 %0D%0A    @Overr
@@ -1294,151 +1294,8 @@
   %7D%0D
-%0A    %0D%0A    public static Position add(Position a, Position b) %7B%0D%0A        return new Position(a.getX() + b.getX(), a.getY() + b.getY());%0D%0A    %7D%0D
 %0A%0D%0A%7D

Add more flexible methods to Position