Homework Assignment 4

A Simple Game: Tic-Tac-Toe


810:062
Computer Science II
Object-Oriented Programming


Due: Friday, October 7, at 11:59 PM


Introduction

This assignment asks you to design your own object-oriented program and build it "from scratch". Your task is to write a program that plays the game of Tic-Tac-Toe against a human player. For now, we will use a text-based interface, though soon in the course we will be able to implement a nice graphical front end to the program.

Tic-Tac-Toe isn't a complex game, so you shouldn't have to spend too much time figuring out the game. We'd like for you to devote most of your time to designing a good program, one that we will be able to extend easily in the future.


Tasks

  1. Design and implement a program to play the game of Tic-Tac-Toe.

    Design your program based on the specification given below. This specification is very simple, listing only a half-dozen required behaviors. You may want to draft a few scenarios in which two players play the game and use these scenarios to drive your design. They will help you to begin to find objects and assign responsibilities to them.

    Then write Java classes to implement your design.

    You may create whatever classes you think best model the problem.

  2. Prepare a "read me" file for your program.

    Create a file named readme.txt that documents the design of your Tic-Tac-Toe program, describing briefly

We will evaluate your program first of all on whether and how well it provides the specified behaviors. Keep in mind: a program that compiles and runs but is incomplete is worth more than a "more complete" program that doesn't compile or that does not run correctly.

Secondly, we will evaluate your program on the quality of the design and implementation. How well are the responsibilities apportioned to independent objects that collaborate to solve the problem? How flexible is the design in the face of reasonable changes to the specification?

Your code and your "read me" file are the only ways you have to communicate your design and implementation, so try to use them to communicate well.


Deliverables

By the due date and time, submit the files

Be sure that your submission follows all homework submission requirements.


A Specification for a Program to Play Tic-Tac-Toe

The game of Tic-Tac-Toe consists of two players, usually known as X and O, placing their marks in a 3x3 grid of squares. X goes first, and the players alternate moves. A player wins the game if she marks three squares in a row horizontally, vertically, or diagonally.

Your program should allow the user to play a number of games of Tic-Tac-Toe against the computer, displaying results of the play to the user.

Your initial implementation provide only a few simple behaviors:

Later, we will add more interesting behaviors to the program, such as different strategies for the computer player, computer-versus-computer and human-versus-human play, graphical interaction, and so on. The program you write for this assignment does not have to provide these behaviors, but you should design your program in a way that allows us to add them easily later. The best way to do this is to make a program with many interacting objects.

Your computer player can choose its move in any way you wish, even randomly. You may implement a "smarter" program if you like!