官术网_书友最值得收藏!

Implementation

This implementation should be similar to the previous one. We already have horizontal verification and now we need to do the same vertically:

private boolean isWin() {
  int playerTotal = lastPlayer * 3;
  for (int i = 0; i < SIZE; i++) {
    if (board[0][i] + board[1][i] + board[2][i] == playerTotal) {
      return true;
    } else if (board[i][0] + board[i][1] + board[i][2] == playerTotal) {
      return true;
    }
  }
  return false;
}
主站蜘蛛池模板: 彰化县| 贺兰县| 二连浩特市| 禹州市| 禄劝| 杭锦后旗| 三门县| 高陵县| 同心县| 巧家县| 丹凤县| 从化市| 凤凰县| 宁海县| 兴隆县| 兴隆县| 中西区| 营山县| 虹口区| 布尔津县| 中卫市| 湘乡市| 汪清县| 金山区| 西充县| 阜新市| 柘荣县| 白河县| 禹城市| 库车县| 准格尔旗| 衡东县| 富平县| 兴隆县| 东至县| 罗甸县| 永宁县| 铁岭市| 贵溪市| 莱西市| 英德市|