O'Reilly logo

Test-Driven Java Development - Second Edition by Viktor Farcic, Alex Garcia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Requirement 4 – the game's output

A few outputs should be added to let the players know the current status of the game.

We want feedback when either an event or an error occurs within the game. The output shows the status of the board after every move.

No output channel is specified. To make it easier, we decided to use the system standard output to print an event when it occurs. A few lines have been added on every action to let the user know about the status of the game:

... private static final String DELIMITER = "|"; private void switchPlayer() { if (Color.RED == currentPlayer) { currentPlayer = Color.GREEN; } else { currentPlayer = Color.RED; } System.out.println("Current turn: " + currentPlayer); } public void printBoard() { for (int ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required