Battleship/src/battleship/model/Direction.java

37 lines
917 B
Java
Raw Normal View History

package battleship.model;
import battleship.utils.Pair;
2021-04-29 11:41:43 +02:00
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public enum Direction {
2021-04-29 11:41:43 +02:00
RIGHT(new Pair<>(0, 1), "D", KeyEvent.VK_RIGHT),
LEFT(new Pair<>(0,-1), "G", KeyEvent.VK_LEFT),
UP(new Pair<>(-1,0), "H", KeyEvent.VK_UP),
DOWN(new Pair<>(1,0), "B", KeyEvent.VK_DOWN),
DEFAULT(new Pair<>(-1,-1), null, KeyEvent.VK_UNDEFINED);
private final Pair<Integer, Integer> direction;
private final String keyword;
2021-04-29 11:41:43 +02:00
private final int arrow;
2021-04-29 11:41:43 +02:00
<K, U> Direction(Pair<Integer, Integer> ukPair, String keyword, int arrow) {
this.direction = ukPair;
this.keyword = keyword;
2021-04-29 11:41:43 +02:00
this.arrow = arrow;
}
public Pair<Integer, Integer> getDirection() {
return direction;
}
public String getKeyword() {
return keyword;
}
2021-04-29 11:41:43 +02:00
public int getArrow() {
return arrow;
}
}