• 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
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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



 
Marshal
Posts: 5988
155
Chrome Eclipse IDE Java Postgres Database Ubuntu 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
Marshal
Posts: 5988
155
Chrome Eclipse IDE Java Postgres Database Ubuntu 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.
 
Marshal
Posts: 64494
225
  • 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.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!