• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to determine the end of a Tic Tac Toe game

 
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



 
Sheriff
Posts: 6127
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • 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: 6127
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • 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.
 
Marshal
Posts: 65105
247
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!