I'm currently in the process of making Tic Tac Toe, and most of it is working. The way I wrote it (Warning: It's written in a god-awful manage) is with
9 buttons, with the a String called letter alternating between X and O, based on a boolean (switching every ActionPerformed). In the ActionPerformed
section, there's a huge load of if statements accounting for every winning possibility (I know, not the best way to do it).
I also have a boolean which makes sure that the button values are not null (So that it only checks the buttons when they have values). There is also
another boolean called 'Win', initially set to false, but when the winning condition is met, it is said to true. When 'Win' is true, then a dialogue box pops up saying 'lettervalue' + "Wins!".
The problem is that, although most of the winning combinations work, some of them do not, and the 'letterValue' stays as a blank string, so it just
comes up as ' Wins!'. After a few hours of debugging, a friend of mine and I managed to figure out that the string was being set before the
Action Performed, so it's reading the blank button.
I've tried to fix it, but no luck, so I need some advice...
The code is attached; any help would be appreciated.