• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to determine the end of a Tic Tac Toe game  RSS feed

 
Lee High
Greenhorn
Posts: 22
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, This latest project has me at a loss. Not sure where to go from here. My instructions are to (A) add a new method named getOutcome that returns an Outcome enumeration. (B) In the takeTurn method, use the getOutcome method to determine whether to continue the game.(C) In the takeTurn method, display a dialog message that displays the winner or tie when the game ends. Optionally,you can clear the board and start a new game after it ends. Note: display a dialog message in the current window: JOptionPane.showMessageDialog (this, "Both players tie.");
Here is what I have so far, I can display the board and apply Nought and Cross but I am unable to work through the game and determine a winner or tie.




Board.java



Mark.java



Outcome.java



Player.java



Cell.java



 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moderator note: I split this question into a new topic.  If a question has changed or a new forum is needed, please use a new topic (thread).
 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CodeRanch Pro Tip: If you search the Java Forums for "Tic Tac Toe" or "Noughts and Crosses" plus win, lose, tie, end, or game you will find that this topic has been discussed before and you may be able to glean some insight into how to solve your problem.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another thing to do would be to play the game very slowly with pencil and paper and when you get to a winning stage, follow what you do very slowly and carefully.
 
Lee High
Greenhorn
Posts: 22
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the advice all, will do.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!