diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-26 05:04:01 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-26 05:04:01 +0000 |
commit | 71baf46654a260fd9edf86e608707542282fc68a (patch) | |
tree | 660e68a2dd45da909d9d73af4341186d87e70a95 /ws2015/eip/Position.java | |
parent | 1f6f843dd3d565b580698904f488a4739e4afa4d (diff) | |
download | uni-71baf46654a260fd9edf86e608707542282fc68a.tar uni-71baf46654a260fd9edf86e608707542282fc68a.tar.gz uni-71baf46654a260fd9edf86e608707542282fc68a.tar.bz2 uni-71baf46654a260fd9edf86e608707542282fc68a.tar.xz uni-71baf46654a260fd9edf86e608707542282fc68a.zip |
More links
Diffstat (limited to 'ws2015/eip/Position.java')
-rw-r--r-- | ws2015/eip/Position.java | 30 |
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 @@ | |||
1 | public 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 | } | ||