RE: tic tac toe 11-13-2013, 08:19 AM
#4
Quote:what i want to do is after the do while is over if we have a winner i wanted to say the winner is player 1 if player 1 won or the winner is player 2 if player 2 won and finally it's a tie if no1 won !!
can u give me ideas on how to do it ?
Instead of returning a boolean let the checkWin return who won.
Look into Enums: http://docs.oracle.com/javase/tutorial/j.../enum.html
Then create an enum type that has the values: PLAYER1, PLAYER2, NO_WINNER
Then you will say something like:
Code:
while ((counter < 9) && (checkWin(board) == NO_WINNER));
if (counter >= 9) {
//tie
} else if (checkWin(board) == PLAYER1) {
//player 1 is winner
} else {
//player 2 is winner
}
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.
Expressed feelings are just an attempt to simulate humans.
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)