Java Code Challenge: Tic-Tac-Toe

DZone 's Guide to

Java Code Challenge: Tic-Tac-Toe

Do you think you've got what it takes to make the cleanest, best-tested command line Tic-Tac-Toe game on DZone? Here's your chance to prove it.

· Java Zone ·
Free Resource

It's been quite some time since our fantastic community proven their coding skills in actual coding instead of some overly theoretical comment wars. Here I come with a potential relief — a coding challenge.

The task is to implement a simple command-line Tic-Tac-Toe game using Java. Of course, merely making it work is only a part of the problem. What we're looking for here is the cleanest, well-tested solution; a design that deserves respect.

To submit your solution, push it to a public GitHub repository and post the link in the comments. The most interesting solutions (or their parts) will be presented and discussed in a post around the beginning of March, so make sure you don't miss the chance for fame and glory!

Minimum Requirements

  • The game runs in the command line. We're more concerned with the internal design than a beautiful GUI.

  • Input is passed in the form of coordinates e.g. "1,1" to place the symbol in the middle of the board.

  • Players play on a 3x3 board, with three consecutive symbols required to win the game.

  • Two human players can play against each other on the same computer.

  • A board is printed after each player moves.

  • The game ends when one of the players wins or the board is full.

Bonus requirements

If you have some spare time or just want to test your design by adding more requirements, here are some ideas:

  • A human player can play against the computer (again, make it clean, no advanced AI required)

  • Boards bigger than just 3x3 are supported.

clean code, code challenge, game development, java

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}