Application Kata "Tic Tac Toe"

Write a console program that allows two players to play [Tic Tac Toe].

When the program starts, a new game begins, which looks like this:

 A B C
0 | |
 -+-+-
1 | |
 -+-+-
2 | |
Command:

The players take it in turns to move by entering the coordinates of the square on which they want to place their tile as a command [1], e.g. "A0" or "C2". The symbol of player 1's tile is "X", that of player 2 is "O".

If a player places his piece on a square that has already been filled, the board is displayed again without any changes. The player may try again.

The game board is redisplayed after each move. If player 1 moves to A0 and then player 2 moves to B1, the board looks like this:

 A B C
0X| |
 -+-+-
1 |O|
 -+-+-
2 | |
Command:

To start a new game, enter "new" instead of a playing field coordinate.

To exit the program, enter "end" as a command.

A game ends when no more moves are possible or a player has won. A corresponding message is displayed, e.g.

 A B C
0X| |
 -+-+-
1X|O|O
 -+-+-
2X| |
*** Player 1 wins
Command:

Once a game has ended, only the "new" and "end" commands are interpreted.

Resources

[Tic Tac Toe] http://de.wikipedia.org/wiki/Tic_Tac_Toe

Endnotes

[1] The commands should be understood without regard to upper/lower case.

en_USEnglish