I have an enum class like this:
public enum Position {
A1(0,0),
A2(1,0),
//etc
public final int dy, dx;
private Position(int dy, int dx) {
this.dy = dy;
this.dx = dx;
}
}
Now I want a method: public static Position getPosition(int dx, int dy)
Can I return Position.A1
or Position.A2
with the given dx
and dy
without using a whole lot of if-structures?