Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


tic tac toe filter_list
Author
Message
RE: tic tac toe #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.

[Image: 2YpkRjy.png]

Reply





Messages In This Thread
tic tac toe - by blackeagle - 11-12-2013, 01:51 AM



Users browsing this thread: 1 Guest(s)