General Question

Johnny4500's avatar

How do I create a tic tac toe?

Asked by Johnny4500 (1points) June 8th, 2022 from iPhone

Please help how do I create a tic tac toe game that asks for the names of the two players and shows the score board. I need to also make a 3×3 grid using JFrame (GUI). I have tried but nothing is working. I looked at other people work but I have to make my own. If you can please provide a step by step procedure

Observing members: 0 Composing members: 0

5 Answers

Response moderated (Unhelpful)
elbanditoroso's avatar

You need to first figure out how to draw the grid, because you will be using it over and over.

Then you need to work on the data entry interface:
– which is X, and which is O
– not overwriting a filled space

Then there is row detecting – how will the code determine if there are three in a row? Up, down, and diagonal.

Probably use a 2-dimensional array to track what blocks are filled (and with what), and then some sort of a comparator set to decide if you have a winner.

Now – do the work.

Zaku's avatar

Learning programming involves a lot of trial and error (and also maybe some reading). When what you have tried doesn’t work, look at what it DID do, and try to understand why it might have done that. Make changes to your code to try to get it to do it a bit differently, see what THAT does, and repeat until you understand why it does what it does. Once you understand enough of how it works, you’ll be able to do whatever you want it to do . . . until you’re surprised again, and then you go back to trial and error (and/or reading) on that part.

Response moderated (Off-Topic)
Alachonnel's avatar

It was the code for me that has always been some kind of dull work that I put off everything, so I liked to use ready-made constructors and write off the code from there, modifying it a little :)

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther