Tic-Tac-Toe Java Two Players | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Tic-Tac-Toe Java Two Players

Hey there, I need help on getting two players to mark on the board with X and O and to check if the squares are available while preventing the players from overwriting each other. I have an idea but can't think of it. I may need some help. Here's my code: https://code.sololearn.com/c0qwVq7OjXsH/#java

7th Dec 2018, 1:24 AM
Spartan Noah- 458
Spartan Noah- 458 - avatar
1 Resposta
+ 1
//Need to check to see if the board is available and that two players can't overwrite the square So, it depends. Are you going to check if there is already any winner? Yes? Then you will just break your loop after check. - better idea No? You are counting turns, so you can just brake it while(turn<9) avoid overwriting - compare current provided coords with board value //Need help with marking X or O on the board based on number You have array "board" and variables "r,c", so you basically have everything you need to mark "O" or "X" .
7th Dec 2018, 8:00 AM
Michal
Michal - avatar