You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
532 B

package de.hsfulda.pmuw.oop;
public enum NeighborPosition {
NORTH(-1, 0),
SOUTH(1, 0),
EAST(0, 1),
WEST(0, -1),
NORTH_EAST(-1, 1),
SOUTH_EAST(1, 1),
SOUTH_WEST(1, -1),
NORTH_WEST(-1, -1);
private final int rowOffset;
private final int columnOffset;
NeighborPosition(int rowOffset, int columnOffset) {
this.rowOffset = rowOffset;
this.columnOffset = columnOffset;
}
int getIndex(int row, int column, int rowSize) {
return (((row + rowOffset) * rowSize) + column + columnOffset);
}
}