COMP 102 Lab4

Building a Tic Tac Toe program

Due Date: Wednesday November 21 at midnight

Summary:

In this lab you will build a tic tac toe program. Your program should let your play a two person game of tic tac toe. That is you will be able to play against another human player, taking turns as the keyboard. As always, read the entire lab before beginning it.Extra credit is available, but only for those who have finished the required part of the lab.


Useful Links:

WxWindows classes (sorted by category)

The wxWindows classes listed alphabetically

A tutorial comparing wxWidgets to MFC classes

Objectives:

In this lab you will:

Your task:

You will create a standard 3x3 tic tac toe game that can be played by two people sharing the mouse. A very basic game might look something like this:































You will use the wxWindows library in developing your application. Several of the classes in the UML diagram below are found in the wxWindows Library

The Requirements:

Start by making a folder called lab4 that you will use to do all of your work for this assignment.

mkdir lab4

do all of your work in this folder so that you can zip up the entire folder to submit it.

Your program should follow the simplified UML class diagram below. The properties and capabilities have been deliberately omitted to allow you more flexibility in designing your program. However, I have included the relationships that you need to implement.

Lab4 minimal UML diagram



Your program should have the following basic behavior:

  1. When the program starts, all squares of your game board should be blank.

  2. When the program starts, the first person to click on a square with the mouse should be the 'X' player, the second person should be the 'O' player.

      1. the program should automatically switch between the X player and the O player with no additional user interaction needed beyond clicking on a square.

  3. When a user clicks on a blank square, the square should change to that players mark (either X or O)

  4. When a user/player clicks on a square that is already selected

      1. if the square is one of the players own, pop up a polite warning message informing the user that he/she has already selected that square.

      2. If the square belongs to the other player, pop up a somewhat sterner warning message like the one below. Make sure that the message is still within the bounds of good taste.







Your program must also observe the following programming constraints.

  1. Your program must have an array of squares. You may not have 9 separate instance variables, with one for each of the nine squares.

  2. No one method can be more than 20 lines of code.

  3. You must use classes and methods. You may not have any c-stye functions in this project. (note that you don't even need a main function so there is no reason to have any c-style functions at all.

When compiling your program, use the instructions for creating a make file that we will go over in class on the day the assignment is given out.

We will go over the parts of the wxWindows library that are important for this lab. You can also consult the documentation available from the wxWindows Website by following the link from the resources page.

Remember to comment your code. You have more freedom than usual to design your program so you need to comment your code well.

Extra Credit:

For those who have completed the entire mandatory part of the lab, there is extra credit available.

  1. For 5 points of extra credit: instead of simple text based “X” and “O”s on the game squares, make large colored X and Os that cover the entire large square (don't just make a little itty bitty square and call it good enough with the standard text X and O

  2. For 10 points of extra credit, check to see if someone has won the game after each players move. If someone has won the game, pop up a message box telling who won the game. When the message box is closed, you should exit the game.

Your Readme file:

As always, you need to include a readme.txt file in your submission. Include the usual details:

zip up your entire lab4 directory and send it to me by email using the same techniques you have used for previous labs.