public static Direction randomDir() { List<Direction> directionList = Collections.unmodifiableList(Arrays.asList(Direction.values())); Random random = new Random(); return directionList.get(random.nextInt(directionList.size())); }
public static Direction actualOpposite(Direction primary) { System.out.println(primary.name()); switch (primary) { case DOWN: return Direction.UP; case UP: return DOWN; case LEFT: return Direction.RIGHT; case RIGHT: return Direction.LEFT; default: return Direction.UP; } }