public boolean isWinner(char player)
{
if (board[0] == player && board[1] == player && board[2] == player ||
board[3] == player && board[4] == player && board[5] == player ||
board[6] == player && board[7] == player && board[8] == player ||
board[0] == player && board[3] == player && board[6] == player ||
board[1] == player && board[4] == player && board[7] == player ||
board[2] == player && board[5] == player && board[8] == player )
return 1;
return 0;
}
/* check to see if the player x is the winner or
the player y is the winner or the cat is the winner
or the game is not over yet and then display the result
you need to write conditional statments*/
public void displayResults()
{
if (isWinner = true)
System.out.print("CONGRATUTIONS " + player + " YOU WON!");
}
Hey I was wondering if anyone could help me on how to pass the the "isWinner" result into "displayResults" if statement. This is for a tic-tac-toe game that we got assigned if this is one of the parts I need help on.
Aucun commentaire:
Enregistrer un commentaire