diff options
Diffstat (limited to 'src/com/fourisland/fourpuzzle/Direction.java')
-rw-r--r-- | src/com/fourisland/fourpuzzle/Direction.java | 100 |
1 files changed, 80 insertions, 20 deletions
diff --git a/src/com/fourisland/fourpuzzle/Direction.java b/src/com/fourisland/fourpuzzle/Direction.java index 4742521..4fa0908 100644 --- a/src/com/fourisland/fourpuzzle/Direction.java +++ b/src/com/fourisland/fourpuzzle/Direction.java | |||
@@ -10,30 +10,90 @@ package com.fourisland.fourpuzzle; | |||
10 | * @author hatkirby | 10 | * @author hatkirby |
11 | */ | 11 | */ |
12 | public enum Direction { | 12 | public enum Direction { |
13 | North, | 13 | North |
14 | East, | 14 | { |
15 | South, | 15 | public Direction opposite() |
16 | West; | 16 | { |
17 | return Direction.South; | ||
18 | } | ||
19 | |||
20 | public Direction left() | ||
21 | { | ||
22 | return Direction.West; | ||
23 | } | ||
24 | |||
25 | public Direction right() | ||
26 | { | ||
27 | return Direction.East; | ||
28 | } | ||
29 | }, | ||
30 | East | ||
31 | { | ||
32 | public Direction opposite() | ||
33 | { | ||
34 | return Direction.West; | ||
35 | } | ||
36 | |||
37 | public Direction left() | ||
38 | { | ||
39 | return Direction.North; | ||
40 | } | ||
41 | |||
42 | public Direction right() | ||
43 | { | ||
44 | return Direction.South; | ||
45 | } | ||
46 | }, | ||
47 | South | ||
48 | { | ||
49 | public Direction opposite() | ||
50 | { | ||
51 | return Direction.North; | ||
52 | } | ||
53 | |||
54 | public Direction left() | ||
55 | { | ||
56 | return Direction.East; | ||
57 | } | ||
58 | |||
59 | public Direction right() | ||
60 | { | ||
61 | return Direction.West; | ||
62 | } | ||
63 | }, | ||
64 | West | ||
65 | { | ||
66 | public Direction opposite() | ||
67 | { | ||
68 | return Direction.East; | ||
69 | } | ||
70 | |||
71 | public Direction left() | ||
72 | { | ||
73 | return Direction.South; | ||
74 | } | ||
75 | |||
76 | public Direction right() | ||
77 | { | ||
78 | return Direction.North; | ||
79 | } | ||
80 | }; | ||
17 | 81 | ||
18 | /** | 82 | /** |
19 | * TODO Find a way to serve the inverse of a Direction without using a | 83 | * Returns the direction opposite from the current one |
20 | * switch, which is apparently bad practice | 84 | * @return A Direction representing the wanted direction |
21 | */ | 85 | */ |
86 | public abstract Direction opposite(); | ||
22 | 87 | ||
23 | /** | 88 | /** |
24 | * Returns the direction opposite from the current one | 89 | * Returns the direction counterclockwise from the current one |
25 | * @return A Direction representing the opposite direction | 90 | * @return A Direction representing the wanted direction |
26 | */ | 91 | */ |
27 | public Direction oppositeDirection() | 92 | public abstract Direction left(); |
28 | { | 93 | |
29 | switch (this) | 94 | /** |
30 | { | 95 | * Returns the direction clockwise from the current one |
31 | case North: return Direction.South; | 96 | * @return A Direction representing the wanted direction |
32 | case West: return Direction.East; | 97 | */ |
33 | case South: return Direction.North; | 98 | public abstract Direction right(); |
34 | case East: return Direction.West; | ||
35 | } | ||
36 | |||
37 | return null; | ||
38 | } | ||
39 | } | 99 | } |