cicaprojekt/cicaprojekt/Direction.java

44 lines
1018 B
Java
Raw Normal View History

package cicaprojekt;
import java.util.Random;
2016-05-16 18:46:28 +00:00
/**
* A játékban előforduló irányokat definiáló enumerátor.
*/
public enum Direction {
2016-05-16 18:46:28 +00:00
/**
* Az irányok felsorolása.
*/
2016-04-24 21:01:34 +00:00
NORTH, SOUTH, EAST, WEST;
2016-05-13 18:26:02 +00:00
2016-05-16 18:46:28 +00:00
/**
* A kapott irány megfordítottjával visszatérő függvény.
*
* @param direction a kapott irány
* @return az irány fordítottja
*/
2016-05-13 18:26:02 +00:00
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;
}
}
2016-05-16 18:46:28 +00:00
/**
* Egy véletlenszerű iránnyal tér vissza.
*
* @return véletlen irány
*/
public static Direction getRandom() {
return Direction.values()[new Random().nextInt(Direction.values().length)];
}
}