diff options
author | Camil Staps | 2015-03-05 12:37:00 +0100 |
---|---|---|
committer | Camil Staps | 2015-03-05 12:37:00 +0100 |
commit | edd4e1301a0c6eb97167e03da1f6ae3aa104affd (patch) | |
tree | 4c2a3a5969466016b3151eec1a4f58f5f394b49b /Week4/src/oo15loipe/Loipe.java | |
parent | Final w4 (diff) |
Updated final version according to feedback
Diffstat (limited to 'Week4/src/oo15loipe/Loipe.java')
-rw-r--r-- | Week4/src/oo15loipe/Loipe.java | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/Week4/src/oo15loipe/Loipe.java b/Week4/src/oo15loipe/Loipe.java index 3ac4fd9..9155988 100644 --- a/Week4/src/oo15loipe/Loipe.java +++ b/Week4/src/oo15loipe/Loipe.java @@ -38,8 +38,27 @@ public class Loipe implements InfoLoipe { * @param pad */ public Loipe (String pad) { + setLoipe(pad); + } + + /** + * Refresh everything based on a new path + * + * @param pad + */ + public final void setLoipe(String pad) { + setWidthAndHeight(pad); + fillLoipe(pad); - // First calculate width and height + path_pointer = 0; + } + + /** + * Set the width and height of the loipe based on a path + * + * @param pad + */ + private void setWidthAndHeight(String pad) { int direction = DIRECTION_NORTH; int maxX = 0, maxY = 0, minX = 0, minY = 0; @@ -83,13 +102,21 @@ public class Loipe implements InfoLoipe { height = maxY - minY + 1; width = maxX - minX + 1; - start = new Punt(-minX, -minY); - // Now fill the Loipe + start = new Punt(-minX, -minY); + } + + /** + * Fill the loipe with fragments based on a path. + * Assumes the width, height and start attributes to be correct. + * + * @param pad + */ + private void fillLoipe(String pad) { loipe = new Fragment[width + 1][height + 1]; path = new Punt[pad.length()]; - current_point = start; - direction = DIRECTION_NORTH; + Punt current_point = start; + int direction = DIRECTION_NORTH; for (int i = 0; i < pad.length(); i++) { path[i] = current_point; |