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.
WxWindows classes (sorted by category)
The wxWindows classes listed alphabetically
A tutorial comparing
wxWidgets to MFC classes
In this lab you will:
implement a lab from scratch with no pre-existing source
Use a library
implement the inheritance relationship
implement method over riding
use the this keyword
develop an event driven program.
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
Start by making a folder called lab4 that you will use to do all of your work for this assignment.
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.
Your program should have the following basic behavior:
When the program starts, all squares of your game board should be blank.
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.
the program should automatically switch between the X player and the O player with no additional user interaction needed beyond clicking on a square.
When a user clicks on a blank square, the square should change to that players mark (either X or O)
When a user/player clicks on a square that is already selected
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.
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.
Your program must have an array of squares. You may not have 9 separate instance variables, with one for each of the nine squares.
No one method can be more than 20 lines of code.
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.
For those who have completed the entire mandatory part of the lab, there is extra credit available.
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
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.
As always, you need to include a readme.txt file in your submission. Include the usual details:
the name of each header/cpp file combo that you are turning in and the class it implements.
how to build and run your program.
What implementation decisions you made
If there is anything missing, incomplete or any bugs in your program
zip up your entire lab4 directory and send it to me by email using the same techniques you have used for previous labs.