MCPcopy Create free account
hub / github.com/careercup/ctci / getWinner

Method getWinner

java/Chapter 17/Question17_2/QuestionB.java:30–41  ·  view source on GitHub ↗
(Piece[][] board, int fixed_index, Check check)

Source from the content-addressed store, hash-verified

28 }
29
30 public static Piece getWinner(Piece[][] board, int fixed_index, Check check) {
31 Piece color = getIthColor(board, fixed_index, 0, check);
32 if (color == Piece.Empty) {
33 return Piece.Empty;
34 }
35 for (int var = 1; var < board.length; var++) {
36 if (color != getIthColor(board, fixed_index, var, check)) {
37 return Piece.Empty;
38 }
39 }
40 return color;
41 }
42
43 /* Only works for 3x3 board */
44 public static Piece hasWon1(Piece[][] board) {

Callers 1

hasWon2Method · 0.95

Calls 1

getIthColorMethod · 0.95

Tested by

no test coverage detected