In order to track who should play next, we need to store who played last:
private char lastPlayer = ' '; public void play(int x, int y) { checkAxis(x); checkAxis(y); setBox(x, y); lastPlayer = nextPlayer(); } public char nextPlayer() { if (lastPlayer == 'X') { return 'O'; } return 'X'; }
You are probably starting to get the hang of it. Tests are small and easy to write. With enough experience, it should take a minute, if not seconds, to write a test and as much time or less to write the implementation.