CS 2121 Introduction to Java:
Programming Assignment 4

Due April 9, 35 points


For this lab you will write a program to play tic tac toe. The game has two players, the user and the computer. The program implements a good, but not perfect, strategy for the computer. When you are finished, your applet should look like the following demonstration applet. To play the game, follow the instructions in the message label at the bottom of the applet. When a "Push Start New Game button." message appears, you can start a game by clicking on the "Start New Game" button.

When a "Your play." message appears, you can make a play by clicking on one of the empty cells. When it is the computer's turn, a "Push Make Computer Play button." message appears. The computer's play will be made when you click on the "Make Computer Play" button.

The message label will announce when the game is over with one of three messages: "Game over: Drawn!", "Game over: I win!", or "Game over: You win!". At this time, you can start a new game by clicking on the "Start New Game" button. The first player for new games will alternate between you and the computer.

Demonstration Applet

The development of this program is broken up into the following steps.