Comments added to Direction.java

This commit is contained in:
Siket Melinda Tekla 2016-05-16 20:46:28 +02:00
parent 6af154f594
commit d9e4873741
1 changed files with 17 additions and 0 deletions

View File

@ -2,9 +2,21 @@ package cicaprojekt;
import java.util.Random;
/**
* A játékban előforduló irányokat definiáló enumerátor.
*/
public enum Direction {
/**
* Az irányok felsorolása.
*/
NORTH, SOUTH, EAST, WEST;
/**
* A kapott irány megfordítottjával visszatérő függvény.
*
* @param direction a kapott irány
* @return az irány fordítottja
*/
public static Direction invert(Direction direction) {
switch (direction) {
case NORTH:
@ -20,6 +32,11 @@ public enum Direction {
}
}
/**
* 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)];
}