mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Legger til en metode for revers retning i Direction
This commit is contained in:
parent
83a8dd35d8
commit
3af159af06
@ -44,4 +44,32 @@ public enum Direction {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the reverse of a direction
|
||||||
|
* @param direction A direction
|
||||||
|
* @return The reverse direction
|
||||||
|
*/
|
||||||
|
public static Direction getReverseDirection(Direction direction) {
|
||||||
|
switch (direction) {
|
||||||
|
case NORTH:
|
||||||
|
return SOUTH;
|
||||||
|
case SOUTH:
|
||||||
|
return NORTH;
|
||||||
|
case EAST:
|
||||||
|
return WEST;
|
||||||
|
case WEST:
|
||||||
|
return EAST;
|
||||||
|
case NORTH_EAST:
|
||||||
|
return SOUTH_WEST;
|
||||||
|
case NORTH_WEST:
|
||||||
|
return SOUTH_EAST;
|
||||||
|
case SOUTH_WEST:
|
||||||
|
return NORTH_EAST;
|
||||||
|
case SOUTH_EAST:
|
||||||
|
return NORTH_WEST;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid input direction.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user