From e58c4a26566e73a84d38d7f871aa21b85f295ea8 Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Tue, 27 Feb 2018 12:24:44 +0100 Subject: [PATCH] changed move --- src/Worm.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Worm.java b/src/Worm.java index a975a1b..8866c84 100644 --- a/src/Worm.java +++ b/src/Worm.java @@ -94,7 +94,13 @@ public class Worm { return this.orientation; } + + /** + * @param orientation + * + */ public void setOrientation(double orientation) { + this.orientation = orientation; } @@ -150,7 +156,7 @@ public class Worm { /** * - * @param NumberSteps + * @param NumberSteps ... * * @post ... * |new.CoordX = CoordX + NumberSteps * distanceX @@ -165,9 +171,9 @@ public class Worm { public void move(int NumberSteps) { if (NumberSteps < 0) throw new IllegalArgumentException(); - double distanceX = getRadius() * Math.cos(getOrientation()); - double distanceY = getRadius() * Math.sin(getOrientation()); - setCoordX(getCoordX() + NumberSteps * distanceX); - setCoordY(getCoordY() + NumberSteps * distanceY); + double distanceX = this.radius * Math.cos(this.orientation); + double distanceY = this.radius * Math.sin(this.orientation); + setCoordX(this.coordX + NumberSteps * distanceX); + setCoordY(this.coordY + NumberSteps * distanceY); } }