From 71baf46654a260fd9edf86e608707542282fc68a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 26 Nov 2015 05:04:01 +0000 Subject: More links --- ws2015/eip/Position.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ws2015/eip/Position.java (limited to 'ws2015/eip/Position.java') 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 @@ +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; + } + +} -- cgit v1.2.3