The main aim is to create a multi-class program, to practice design, classes, objects, libraries, unit testing, and style. Please provide short comments on the code so I can understand where these have been achieved. I will need either of these additions to the program (please also explain how it is achieved in a .txt or commented in the code):

  • Graphics, OR
  • Networking to play on two different computers, OR
  • AI component, so a human can play against the computer.

The program:

The idea is to write a program called which allows two people to play the game Noughts and Crosses (or Tic-Tac-Toe if you are American) using just text. It would be reasonably easy to write this program in one piece, but you are asked to deliberately over-engineer it, as if it were a bigger project, to show off your object oriented skills. Here are some suggested classes:

  • A Board class, to represent the current state of the game, i.e. a 3x3 grid, plus which player's turn it is to move next. It should probably also be responsible for checking whether moves are valid or not, whether a player has just won or not, or whether the game is a draw. This is the main logic of the game, so this class needs unit testing.
  • A Position class to represent a position on the 3x3 playing board.
  • An enumerated type class, or some other way to represent the possible values that can appear on the board (an X, an O, or blank) in a symbolic way.
  • A Display class, which deals with printing out the board as text, and with receiving inputs from the players
  • An Oxo class which controls everything

A board might be printed out like this (or something similar which indicates row letters and column numbers):

a OX.
b ..X
c ...

The two players might use the same keyboard to type in moves:

Player O's move: b2

Some things you might like to know, and which might be helpful, are:

  • You can use System.out.print to print out text without a newline, e.g. as a prompt
  • You can put import java.util.*; at the top of your program to import a helpful collection of utility classes, and/or import*; for input/output classes
  • Either the Scanner or Console class can be used to help with reading lines of text from the user


Some things which I am looking for are: good design (probably along the lines I have suggested, but in any case with "the right code in the right place"), good style (DRY, consistent, commented but not over-commented code), no statics (except for main methods), private fields (except maybe for immutable objects), defensive programming (i.e. testing for bad things even though they shouldn't happen, to improve debugging), unit testing (to convince me that your classes do what they should), robustness (to convince me that your classes don't do what they shouldn't).

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.