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

Method getIthColor

java/Chapter 17/Question17_2/QuestionB.java:16–28  ·  view source on GitHub ↗
(Piece[][] board, int index, int var, Check check)

Source from the content-addressed store, hash-verified

14 }
15
16 public static Piece getIthColor(Piece[][] board, int index, int var, Check check) {
17 int N = board.length;
18 if (check == Check.Row) {
19 return board[index][var];
20 } else if (check == Check.Column) {
21 return board[var][index];
22 } else if (check == Check.Diagonal) {
23 return board[var][var];
24 } else if (check == Check.ReverseDiagonal) {
25 return board[N - 1 - var][var];
26 }
27 return Piece.Empty;
28 }
29
30 public static Piece getWinner(Piece[][] board, int fixed_index, Check check) {
31 Piece color = getIthColor(board, fixed_index, 0, check);

Callers 1

getWinnerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected