diff options
Diffstat (limited to 'src/ch/epfl/maze/util')
-rw-r--r-- | src/ch/epfl/maze/util/Action.java | 8 | ||||
-rw-r--r-- | src/ch/epfl/maze/util/Direction.java | 12 | ||||
-rw-r--r-- | src/ch/epfl/maze/util/LabyrinthGenerator.java | 21 | ||||
-rw-r--r-- | src/ch/epfl/maze/util/Statistics.java | 8 | ||||
-rw-r--r-- | src/ch/epfl/maze/util/Vector2D.java | 16 |
5 files changed, 5 insertions, 60 deletions
diff --git a/src/ch/epfl/maze/util/Action.java b/src/ch/epfl/maze/util/Action.java index 25509a4..069f135 100644 --- a/src/ch/epfl/maze/util/Action.java +++ b/src/ch/epfl/maze/util/Action.java | |||
@@ -5,7 +5,6 @@ package ch.epfl.maze.util; | |||
5 | * about it, such as if it was successful or not, and if the animal will die | 5 | * about it, such as if it was successful or not, and if the animal will die |
6 | * <i>while</i> performing it. | 6 | * <i>while</i> performing it. |
7 | */ | 7 | */ |
8 | |||
9 | public final class Action { | 8 | public final class Action { |
10 | 9 | ||
11 | /* variables defining the action */ | 10 | /* variables defining the action */ |
@@ -19,7 +18,6 @@ public final class Action { | |||
19 | * | 18 | * |
20 | * @param dir Direction towards which the action needs to be performed | 19 | * @param dir Direction towards which the action needs to be performed |
21 | */ | 20 | */ |
22 | |||
23 | public Action(Direction dir) { | 21 | public Action(Direction dir) { |
24 | if (dir != null) { | 22 | if (dir != null) { |
25 | mDirection = dir; | 23 | mDirection = dir; |
@@ -37,7 +35,6 @@ public final class Action { | |||
37 | * @param dir Direction towards which the action needs to be performed | 35 | * @param dir Direction towards which the action needs to be performed |
38 | * @param successful Determines whether this action was successful | 36 | * @param successful Determines whether this action was successful |
39 | */ | 37 | */ |
40 | |||
41 | public Action(Direction dir, boolean successful) { | 38 | public Action(Direction dir, boolean successful) { |
42 | mDirection = dir; | 39 | mDirection = dir; |
43 | mSuccess = successful; | 40 | mSuccess = successful; |
@@ -53,7 +50,6 @@ public final class Action { | |||
53 | * @param successful Determines whether this action was successful | 50 | * @param successful Determines whether this action was successful |
54 | * @param dies Determines whether the action will die between two squares | 51 | * @param dies Determines whether the action will die between two squares |
55 | */ | 52 | */ |
56 | |||
57 | public Action(Direction dir, boolean successful, boolean dies) { | 53 | public Action(Direction dir, boolean successful, boolean dies) { |
58 | mDirection = dir; | 54 | mDirection = dir; |
59 | mSuccess = successful; | 55 | mSuccess = successful; |
@@ -65,7 +61,6 @@ public final class Action { | |||
65 | * | 61 | * |
66 | * @return Direction of the action | 62 | * @return Direction of the action |
67 | */ | 63 | */ |
68 | |||
69 | public Direction getDirection() { | 64 | public Direction getDirection() { |
70 | return mDirection; | 65 | return mDirection; |
71 | } | 66 | } |
@@ -75,7 +70,6 @@ public final class Action { | |||
75 | * | 70 | * |
76 | * @return <b>true</b> if the action was successful, <b>false</b> otherwise | 71 | * @return <b>true</b> if the action was successful, <b>false</b> otherwise |
77 | */ | 72 | */ |
78 | |||
79 | public boolean isSuccessful() { | 73 | public boolean isSuccessful() { |
80 | return mSuccess; | 74 | return mSuccess; |
81 | } | 75 | } |
@@ -87,8 +81,8 @@ public final class Action { | |||
87 | * @return <b>true</b> if the action dies between two squares, <b>false</b> | 81 | * @return <b>true</b> if the action dies between two squares, <b>false</b> |
88 | * otherwise | 82 | * otherwise |
89 | */ | 83 | */ |
90 | |||
91 | public boolean diesBetweenSquares() { | 84 | public boolean diesBetweenSquares() { |
92 | return mDies; | 85 | return mDies; |
93 | } | 86 | } |
87 | |||
94 | } | 88 | } |
diff --git a/src/ch/epfl/maze/util/Direction.java b/src/ch/epfl/maze/util/Direction.java index 5f83c22..d2ee4e7 100644 --- a/src/ch/epfl/maze/util/Direction.java +++ b/src/ch/epfl/maze/util/Direction.java | |||
@@ -7,14 +7,12 @@ package ch.epfl.maze.util; | |||
7 | * | 7 | * |
8 | * @author Pacien TRAN-GIRARD | 8 | * @author Pacien TRAN-GIRARD |
9 | */ | 9 | */ |
10 | |||
11 | public enum Direction { | 10 | public enum Direction { |
12 | DOWN, UP, RIGHT, LEFT, NONE; | 11 | DOWN, UP, RIGHT, LEFT, NONE; |
13 | 12 | ||
14 | /** | 13 | /** |
15 | * An array of all the possible directions that can be taken. | 14 | * An array of all the possible directions that can be taken. |
16 | */ | 15 | */ |
17 | |||
18 | public static final Direction[] POSSIBLE_DIRECTIONS = new Direction[]{ | 16 | public static final Direction[] POSSIBLE_DIRECTIONS = new Direction[]{ |
19 | Direction.DOWN, | 17 | Direction.DOWN, |
20 | Direction.UP, | 18 | Direction.UP, |
@@ -27,7 +25,6 @@ public enum Direction { | |||
27 | * | 25 | * |
28 | * @return Integer value of the direction | 26 | * @return Integer value of the direction |
29 | */ | 27 | */ |
30 | |||
31 | public int intValue() { | 28 | public int intValue() { |
32 | switch (this) { | 29 | switch (this) { |
33 | case DOWN: | 30 | case DOWN: |
@@ -53,7 +50,6 @@ public enum Direction { | |||
53 | * | 50 | * |
54 | * @return Orthonormal {@code Vector2D} that represents the direction. | 51 | * @return Orthonormal {@code Vector2D} that represents the direction. |
55 | */ | 52 | */ |
56 | |||
57 | public Vector2D toVector() { | 53 | public Vector2D toVector() { |
58 | switch (this) { | 54 | switch (this) { |
59 | case DOWN: | 55 | case DOWN: |
@@ -79,7 +75,6 @@ public enum Direction { | |||
79 | * | 75 | * |
80 | * @return The opposite direction. | 76 | * @return The opposite direction. |
81 | */ | 77 | */ |
82 | |||
83 | public Direction reverse() { | 78 | public Direction reverse() { |
84 | switch (this) { | 79 | switch (this) { |
85 | case DOWN: | 80 | case DOWN: |
@@ -107,7 +102,6 @@ public enum Direction { | |||
107 | * @return <b>true</b> if the direction is the opposite the argument, | 102 | * @return <b>true</b> if the direction is the opposite the argument, |
108 | * <b>false</b> otherwise | 103 | * <b>false</b> otherwise |
109 | */ | 104 | */ |
110 | |||
111 | public boolean isOpposite(Direction d) { | 105 | public boolean isOpposite(Direction d) { |
112 | return this == d.reverse(); | 106 | return this == d.reverse(); |
113 | } | 107 | } |
@@ -120,7 +114,6 @@ public enum Direction { | |||
120 | * @return The direction converted to the frame of reference given by the | 114 | * @return The direction converted to the frame of reference given by the |
121 | * direction called. | 115 | * direction called. |
122 | */ | 116 | */ |
123 | |||
124 | public Direction relativeDirection(Direction dir) { | 117 | public Direction relativeDirection(Direction dir) { |
125 | switch (this) { | 118 | switch (this) { |
126 | case DOWN: | 119 | case DOWN: |
@@ -148,7 +141,6 @@ public enum Direction { | |||
148 | * @return The direction converted back to the frame of reference of the | 141 | * @return The direction converted back to the frame of reference of the |
149 | * labyrinth | 142 | * labyrinth |
150 | */ | 143 | */ |
151 | |||
152 | public Direction unRelativeDirection(Direction dir) { | 144 | public Direction unRelativeDirection(Direction dir) { |
153 | switch (this) { | 145 | switch (this) { |
154 | case DOWN: | 146 | case DOWN: |
@@ -174,7 +166,6 @@ public enum Direction { | |||
174 | * | 166 | * |
175 | * @return The rotated direction to the right | 167 | * @return The rotated direction to the right |
176 | */ | 168 | */ |
177 | |||
178 | public Direction rotateRight() { | 169 | public Direction rotateRight() { |
179 | switch (this) { | 170 | switch (this) { |
180 | case DOWN: | 171 | case DOWN: |
@@ -200,7 +191,6 @@ public enum Direction { | |||
200 | * | 191 | * |
201 | * @return The rotated direction to the left | 192 | * @return The rotated direction to the left |
202 | */ | 193 | */ |
203 | |||
204 | public Direction rotateLeft() { | 194 | public Direction rotateLeft() { |
205 | switch (this) { | 195 | switch (this) { |
206 | case DOWN: | 196 | case DOWN: |
@@ -230,7 +220,6 @@ public enum Direction { | |||
230 | * @return The directions converted to the frame of reference given by the | 220 | * @return The directions converted to the frame of reference given by the |
231 | * direction which calls the method | 221 | * direction which calls the method |
232 | */ | 222 | */ |
233 | |||
234 | public Direction[] relativeDirections(Direction[] dir) { | 223 | public Direction[] relativeDirections(Direction[] dir) { |
235 | Direction[] relativeDirections = new Direction[dir.length]; | 224 | Direction[] relativeDirections = new Direction[dir.length]; |
236 | 225 | ||
@@ -240,4 +229,5 @@ public enum Direction { | |||
240 | 229 | ||
241 | return relativeDirections; | 230 | return relativeDirections; |
242 | } | 231 | } |
232 | |||
243 | } | 233 | } |
diff --git a/src/ch/epfl/maze/util/LabyrinthGenerator.java b/src/ch/epfl/maze/util/LabyrinthGenerator.java index 3e83ec5..9e47c25 100644 --- a/src/ch/epfl/maze/util/LabyrinthGenerator.java +++ b/src/ch/epfl/maze/util/LabyrinthGenerator.java | |||
@@ -10,7 +10,6 @@ import java.util.regex.Pattern; | |||
10 | /** | 10 | /** |
11 | * Generates a set of pre-computed labyrinth structures | 11 | * Generates a set of pre-computed labyrinth structures |
12 | */ | 12 | */ |
13 | |||
14 | public final class LabyrinthGenerator { | 13 | public final class LabyrinthGenerator { |
15 | 14 | ||
16 | /** | 15 | /** |
@@ -18,7 +17,6 @@ public final class LabyrinthGenerator { | |||
18 | * | 17 | * |
19 | * @return A small labyrinth | 18 | * @return A small labyrinth |
20 | */ | 19 | */ |
21 | |||
22 | public static int[][] getSmall() { | 20 | public static int[][] getSmall() { |
23 | int[][] labyrinth = { | 21 | int[][] labyrinth = { |
24 |