public boolean checkCell(char[][] a, int x, int y) {
    int adj = 0;

    if (x > 0 && a[x - 1][y] == 'o') {
      adj++;
    }
    if (y > 0 && a[x][y - 1] == 'o') {
      adj++;
    }
    if (x < a.length - 1 && a[x + 1][y] == 'o') {
      adj++;
    }
    if (y < a.length - 1 && a[x][y + 1] == 'o') {
      adj++;
    }

    return (adj % 2 == 0);
  }