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

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;
}
主站蜘蛛池模板: 繁昌县| 呼伦贝尔市| 盈江县| 景谷| 崇阳县| 兴城市| 德兴市| 广德县| 波密县| 兰州市| 六安市| 于田县| 子长县| 枞阳县| 上虞市| 蕲春县| 融水| 墨玉县| 金坛市| 汾阳市| 哈密市| 蚌埠市| 抚宁县| 卢湾区| 改则县| 临沭县| 惠水县| 繁昌县| 南充市| 稷山县| 宁德市| 崇文区| 额济纳旗| 新龙县| 扶风县| 泸西县| 曲沃县| 乡宁县| 宝清县| 金山区| 定襄县|