Class 25:
public static int posInteger(Stirng s) {
try {
int n = Integer.parseInt(s);
if (n > 0)
return n;
return -1;
} catch (Exception e) {
return -1;
}
}
public static boolean rowWin(char[] list) {
if (list.length == 0)
return false; /* or true */
if ((list[0] != 'X') && (list[0] != 'O'))
return false;
for (int i=1;i<list.length;i++)
if (list[i] != list[0])
return false;
return true;
}
public static boolean rowWin(char[][] board, int n, char c) {
for (int i=0;i<board[n].length;i++)
if (board[n][i] != c)
return false;
return true;
}
public static boolean colWin(char[][] board, int n, char c) {
for (int i=0;i<board.length;i++)
if (board[i][n] != c)
return false;
return true;
}