summaryrefslogtreecommitdiff
path: root/ws2015/eip/Position.java
blob: 9fa5a230927bf5338d57f9af5730f434113f2e2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 this.x;
    }

    public int getY(){
        return this.y;
    }
    
    public Position translate(int dx, int dy){
        return new Position(this.x + dx, this.y + dy);
    }

    double distance(Position other) {
        return  Math.sqrt(Math.pow(this.x - other.x, 2) + Math.pow(this.y - other.y, 2));
    }

    boolean istGleichZu(Position other) {
        return this.x==other.x && this.y==other.y;
    }

}