Lab 13

Don't forget to finish the quiz first.

Lab assignment: Introduction to structs

In this week's lab you must modify a C/C++ program to utilize a struct.

The code given is a mostly completed framework for a simplified game of Tic Tac Toe.  However, the author couldn't decide on how to store the board, so the program doesn't work.  It's up to you to define a Turn struct, and integrate it into the program.

For the first point, define a struct by the name of Turn which stores the turn number and also the board.  The board should probably be an array of characters, though you can use whatever works.  Flesh out the game using the Turn struct to write printBoard and makeMove, and see that the game runs alright.

For the second point, add an array of Turn structs of length 9, and store each of the states of the game in the array.  Write the function printEntireGame, which can be called at the end to "replay" the entire game.

For a third point, write a method called storeCurrentGameInfo which takes one Turn and the history of turns, searches through the history (array of turns) until it finds a "blank space", and stores the turn which was passed in there.  You may want to change the way you initialize the array of structs to get this to work right.  Use printEntireGame to check whether your function is working correctly.

So, use the code given to get this game of Tic Tac Toe off of the ground.  You do not need to add error checking, either in terms of the input or whether the space is already taken, and you do not need to end the game when a winning condition is reached.

Don't worry about comments, coding conventions, or error checking of the input for this submission, though if you have free time it does make the code nicer.

Do put the names and netIDs of both partners in a comment at the top, as well as the lab section you are in.

Be sure to take turns coding!  It's easy to get wrapped up in the coding and forget to give your partner their turn on the keyboard, and it's too easy to sit back and discuss the problem without writing the code yourself.

Submission:

1. You should work with a partner for this lab.  Only one of you needs to submit the program to Blackboard.  Both names must be present in the program you submit.

2. You have until noon on 4/12 (tomorrow) to submit the lab to Blackboard.  Plan your time wisely, and ask questions if you are working but can not progress.

3. You may use either C or C++ to complete this assignment, but be sure you use the appropriate extension for your submission.  Also, executables will not be accepted, so please do not submit any a.outs or their like.