boolean xNeg = xPoint < 0;
boolean yNeg = yPoint < 0;
boolean xZero = xPoint == 0;
boolean yZero = yPoint == 0;
, 2 ^ 4 , Directions ...
int index =
((xNeg ?1:0)<<3)|
((yNeg ?1:0)<<2)|
((xZero?1:0)<<1)|
((yZero?1:0)<<0);
Directions dir = directions[index];
directions a static final , .
static final Directions[] directions = {
Direction.NorthEast, // false, false, false, false ==> x > 0 && y > 0
Direction.East, // false, false, false, true ==> x > 0 && y == 0
Direction.North, // false, false, true , false ==> x == 0 && y > 0
...
}
, , / , , , , Java 1.0.