There are a couple of examples from a simple game based on two players putting X and O on 2d array
First method should return true if element filed[y][x] is ok;
public boolean yxInField(int y, int x, char[][] field) {
return field != null
&& y >= 0
&& x >= 0
&& y < field.length
&& field[y] != null
&& x < field[y].length;
}
Second should return true if at least one of calls of check win condition for a specific direction returned true
public boolean checkWin(int y, int x, char[][] field) {
return
//E-W
checkDirection(y, x, 0, -1, field)
//S-N
|| checkDirection(y, x, -1, 0, field)
//SE-NW
|| checkDirection(y, x, -1, -1, field)
//SW-NE
|| checkDirection(y, x, -1, 1, field);
}
But i'm not certain if this style is ok. If not what would be the better way to do those methods?