package sudoku.structure;

/**
 * Représente les coordonnées d'une Cell
 */
public class Coordinate {

    /**
     * L'abscisse de la Cell.
     */
    private int x;
    /**
     * L'ordonnée de la Cell.
     */
    private int y;

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

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int calculateIndex(int size) {
        return this.y * size + this.x;
    }

    public Coordinate add(Coordinate other) {
        return new Coordinate(this.x + other.x, this.y + other.y);
    }

    public Coordinate sub(Coordinate other) {
        return new Coordinate(this.x - other.x, this.y - other.y);
    }

}
