diff options
author | Camil Staps | 2015-05-29 12:06:42 +0200 |
---|---|---|
committer | Camil Staps | 2015-05-29 12:06:42 +0200 |
commit | a68fa3c3c96c38b811755022089cb8aee2f5521c (patch) | |
tree | ef1463ba40bffedfb22aeca5547c7129c2dc3aca /Week14 Route 66/src/OO14route66/Direction.java | |
parent | Overviewer without Map (diff) |
Intermediate commit: works partially, but sometimes cars go over each other (Crossing.isAllowed() is not synchronized)
Diffstat (limited to 'Week14 Route 66/src/OO14route66/Direction.java')
-rw-r--r-- | Week14 Route 66/src/OO14route66/Direction.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Week14 Route 66/src/OO14route66/Direction.java b/Week14 Route 66/src/OO14route66/Direction.java index b8c1636..14d7110 100644 --- a/Week14 Route 66/src/OO14route66/Direction.java +++ b/Week14 Route 66/src/OO14route66/Direction.java @@ -37,6 +37,21 @@ public enum Direction } } } + + /** + * Get the opposite of a direction + * @param direction + * @return + */ + public static Direction opposite(Direction direction) { + switch (direction) { + case North: return South; + case South: return North; + case East: return West; + case West: return East; + default: return direction; + } + } /** * override standard toString |