CS 161 Homework 8 - Tic-Tac-Toe

Due Mon Nov 25 at 11:59pm

Overview

In this assignment, you will be making another computer version of a simple game: in this case, Tic Tac Toe. While you are actually perfectly capable of enabling a computer to play (and win!) at this game, for this assignment you will just be making a graphical program that allows two humans sitting at the same computer to play together.

Your program will present the player with a window containing 9 buttons--one button for each spot on the grid. Players will take turns making their moves by clicking buttons. Note that the game should make sure the players don't select an invalid move! If one player gets three-in-a-row, the program will congratulate them with a pop-up window, such as:

Once a player has won (or there are no more possible moves), the game resets for the next round.

This assignment should be completed individually. You are welcome to ask for help (either from me or from your classmates), but remember the Gilligan's Island rule!

Objectives

Necessary Files

You will be creating your own program from scratch for this assignment! Details on the classes you will be creating are below.

You will need to download a copy of the README.txt (right-click on the link and select "Save Link As" to download the file) to fill out and turn in along with your assignment. Be sure and place a completed version of this file in your project folder before you upload it!

Assignment Details

This assignment is smaller and simpler than the previous ones, but you have less time to complete it in. Be sure and get started ASAP, and make sure to add a little bit of functionality each day.

For this assignment you will be implementing two classes. The first, TicTacToeGame will be a class that models a game of tic-tac-toe. This class will be similar it functionality to your HangmanGame class from the previous homework, except that you won't have a "game loop" like you did with the playGame() method (instead, each "turn" of the game will be executed by clicking buttons in the interface). The second class, TicTacToeFrame will provide a graphical interface to your TicTacToeGame--it will be able to call methods on the game when players take turns or to figure out what should be displayed.

Note that all your "game" logic should go in the TicTacToeGame class, and all our your input/output should go in the TicTacToeFrame class. In effect, you should be able to play the TicTacToeGame without needing the frame (by calling the proper methods).

You can complete these classes in either order--you can even complete them simultaneously, adding methods to both. You can also easily create the TicTacToeGame class and test that to perfection, then add in the Frame.

TicTacToeGame

This class will model the game of tic-tac-toe. It should keep track of the board (the grid of letters), as well as which player's turn it is.

Your class should include the following methods:

TicTacToeFrame

This class will provide the graphical interface for your TicTacToeGame class.

Extensions

There are a number of other extensions you could add for fun. However, no extra credit is available on this assignment.

Submitting Your Assignment

Grading

This assignment will be graded on approximately the following criteria: