I am basically trying to make a TicTacToe game in Netbeans GUI builder. I have nine(3x3) buttons to show a grid for the game and that's where you mark X and O's. I want to make it one player game.
I wanted to know how to make an array of buttons(JButton).?It is needed to conveniently flip over different buttons.
In the game, computer would need to play with another player and has to mark O and X randomly across nine buttons. So , can you pls also tell me how to randomly shuffle over elements in button array and choose a button that is not currently marked, which would be used by computer player to mark his turn.?
I have not started with the code yet, so i am giving any sample code. Your help would be greatly appreciated. Pls help
Jump to Post
choose a button that is not currently marked
When you chose a button, test if it is marked (how are you marking the buttons) and if it is marked, chose another one.
how to randomly shuffle over elements in button array
Use the Random class to …
All 6 RepliesReply to this topic
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.