package tsp.pacman;

import java.util.Objects;

public class Position {

    private int row;
    private int col;

    public Position(int row, int col){
        this.row = row;
        this.col = col;
    }

    public int getRow(){
        return row;
    }

    public int getCol(){
        return col;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Position position = (Position) o;
        return row == position.row && col == position.col;
    }

    @Override
    public int hashCode() {
        return Objects.hash(row, col);
    }

    @Override
    public String toString() {
        return "tsp.pacman.Position{" +
                "x=" + row +
                ", y=" + col +
                '}';
    }

    public int dist(Position other){
        return Math.abs(this.row - other.row) + Math.abs(this.col - other.col);
    }

    public static void main(String[] args) {
        Position position1 = new Position(1, 5);
        Position position2 = new Position(4, 3);
        System.out.println(position1 + " " + position2);
        System.out.println(position1.dist(position2));
    }
}
