cicaprojekt/cicaprojekt/Direction.java

27 lines
630 B
Java

package cicaprojekt;
import java.util.Random;
public enum Direction {
NORTH, SOUTH, EAST, WEST;
public static Direction invert(Direction direction) {
switch (direction) {
case NORTH:
return SOUTH;
case EAST:
return WEST;
case SOUTH:
return NORTH;
case WEST:
return EAST;
default:
return NORTH;
}
}
public static Direction getRandom() {
return Direction.values()[new Random().nextInt(Direction.values().length)];
}
}