aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ch/epfl/xblast/Direction.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/ch/epfl/xblast/Direction.java b/src/ch/epfl/xblast/Direction.java
new file mode 100644
index 0000000..ea0960d
--- /dev/null
+++ b/src/ch/epfl/xblast/Direction.java
@@ -0,0 +1,51 @@
1package ch.epfl.xblast;
2
3/**
4 * A Direction.
5 *
6 * @author Pacien TRAN-GIRARD (261948)
7 */
8public enum Direction {
9
10 N, E, S, W;
11
12 /**
13 * Returns the opposite Direction.
14 *
15 * @return the opposite Direction
16 */
17 public Direction opposite() {
18 switch (this) {
19 case N:
20 return S;
21 case S:
22 return N;
23 case E:
24 return W;
25 case W:
26 return E;
27 default:
28 return null;
29 }
30 }
31
32 /**
33 * T(the Direction is horizontal to the screen (East or West)).
34 *
35 * @return T(the Direction is horizontal to the screen)
36 */
37 public boolean isHorizontal() {
38 return this == E || this == W;
39 }
40
41 /**
42 * T(the current and given Directions are parallel (identical or opposite)).
43 *
44 * @param that a Direction to compare
45 * @return T(the current and given Directions are parallel)
46 */
47 public boolean isParallelTo(Direction that) {
48 return that == this || that == this.opposite();
49 }
50
51}