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

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;
}
主站蜘蛛池模板: 浦县| 镇坪县| 玉林市| 汨罗市| 梧州市| 金堂县| 怀安县| 佛冈县| 南开区| 田林县| 水富县| 即墨市| 峨眉山市| 四子王旗| 巢湖市| 慈利县| 合川市| 碌曲县| 阳城县| 滨海县| 朝阳县| 常山县| 广宁县| 麻阳| 手游| 舒兰市| 江都市| 化德县| 遂昌县| 布尔津县| 卢湾区| 南召县| 黄山市| 磴口县| 乌兰察布市| 汉阴县| 咸丰县| 武鸣县| 彭州市| 门头沟区| 瓮安县|