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

Test – winning condition III

Now that horizontal and vertical lines are covered, we should move our attention to diagonal combinations:

@Test 
public void whenPlayAndTopBottomDiagonalLineThenWinner() {
  ticTacToe.play(1, 1); // X
  ticTacToe.play(1, 2); // O
  ticTacToe.play(2, 2); // X
  ticTacToe.play(1, 3); // O
  String actual = ticTacToe.play(3, 3); // X
  assertEquals("X is the winner", actual);
}

The player wins when the whole diagonal line from the top-left to bottom-right is occupied by his pieces.
主站蜘蛛池模板: 新竹县| 噶尔县| 襄城县| 平顺县| 博爱县| 宜丰县| 来安县| 凤城市| 宜丰县| 望江县| 盐山县| 富平县| 合江县| 河北区| 新民市| 上栗县| 札达县| 敦化市| 广河县| 故城县| 嘉鱼县| 司法| 北流市| 左权县| 灵丘县| 广水市| 淮南市| 汝南县| 康定县| 平武县| 内黄县| 浦江县| 武安市| 宁强县| 安多县| 兴国县| 平定县| 金山区| 长岭县| 五寨县| 汉源县|