Mastering Java Swing
Score Counter - STEP 9
Tic Tac Toe GameNow let's add score tracking for X and O wins to the game.
At the top of the class, add two integer variables to hold the number of wins for X and O, and two JLabel variables to display the scores:
private int xWins = 0;
private int oWins = 0;
private JLabel xWinLabel;
private JLabel oWinLabel;Members only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 27 more lessons in Mastering Java Swing.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.