summaryrefslogtreecommitdiff
path: root/ws2015/eip/Position.java
diff options
context:
space:
mode:
Diffstat (limited to 'ws2015/eip/Position.java')
-rw-r--r--ws2015/eip/Position.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/ws2015/eip/Position.java b/ws2015/eip/Position.java
new file mode 100644
index 0000000..9fa5a23
--- /dev/null
+++ b/ws2015/eip/Position.java
@@ -0,0 +1,30 @@
1public class Position {
2 private final int x;
3 private final int y;
4
5 public Position(int x, int y) {
6 this.x = x;
7 this.y = y;
8 }
9
10 public int getX(){
11 return this.x;
12 }
13
14 public int getY(){
15 return this.y;
16 }
17
18 public Position translate(int dx, int dy){
19 return new Position(this.x + dx, this.y + dy);
20 }
21
22 double distance(Position other) {
23 return Math.sqrt(Math.pow(this.x - other.x, 2) + Math.pow(this.y - other.y, 2));
24 }
25
26 boolean istGleichZu(Position other) {
27 return this.x==other.x && this.y==other.y;
28 }
29
30}