This lab is worth 10 points and accounts for 12.5 percent of your laboratory grade. The points will be subjectively assigned by your TA based upon whether they believe you made a good faith effort toward complete the tasks that are assigned. Showing up on time, respecting your fellow classmates learning environment, and adherance to laboratory policies also factor into the determination of your score.
Todays lab will be a little bit different than those that you have done so for for this class. In this lab we will experiment with what it's like to work on a large software project where you only work on a small part and must rely on others you are working with in order for the project to be successful.
Your TA will divide you up into different teams ( given that there are enough people ). Within a team you will subdivide yourselves into groups( These groups will be described later ). Each team will be working toward creating a working Tic-tac-toe game. Each group withing a team will be working on a specific part of that Tic-tac-toe game. The goal in the end will be to have a working Tic-tac-toe game that is composed of modules build by different groups.
Three of the groups will be given the public interface to a class. It is their responsibility to implement that class so that it works correctly when combined with the code from other groups.
Each team will be composed of 5 groups. The groups will only be able to communicate through e-mails, except where stipulated below.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Constructors and Destructors ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public: //! \brief Default constructor for the TttCell class. TttCell(); //! \brief Constructor for the TttCell class. //! \param ul_corner The upper left hand corner of the cell. //! \param size The height and width of the cell. TttCell( const Point & ul_corner, const double size ); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Accessors ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Draw the TttCell in the drawing area. //! \return Void. virtual void draw() const; //! \brief Move the object by a displacement. //! \param x_displace The distance to move the object in the x-direction. //! \param y_displace The distance to move the object in the y-direction. //! \return void. virtual void move( const double x_displace, const double y_displace ); //! \brief Test to see if the cell is empty. //! \return Whether the TttCell is empty. bool isEmpty() const; //! \brief Test to see if the cell contains an X. //! \return Whether the TttCell contains an X. bool isX() const; //! \brief Test to see if the cell contains an O. //! \return Whether the TttCell contains an O. bool isO() const; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Mutators ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Reset the TttCell to be empty. //! \return Void. void reset(); //! \brief Set the cell to contain an X. //! \return Void. void setAsX(); //! \brief Set the cell to contain an O. //! \return Void. void setAsO();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Constructors and Destructors ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Default constructor for the TttBoard class. TttBoard(); //! \brief Constructor for the TttBoard class. //! \param ul_corner The upper left hand corner of the board. //! \param size The height and width of the board. TttBoard( const Point & ul_corner, const double size ); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Accessors ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Draw the TttBoard in the drawing area. //! \return Void. virtual void draw() const; //! \brief Move the object by a displacement. //! \param x_displace The distance to move the object in the x-direction. //! \param y_displace The distance to move the object in the y-direction. //! \return void. virtual void move( const double x_displace, const double y_displace ); //! \brief Test to see if the board has been won. //! \return Whether the board has been won. bool isWon() const; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Mutators ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Reset the TttBoard so that all cells are empty. //! \return Void. void reset(); //! \brief Attempt to fill the cell that is clicked with an X or O. //! //! An attempt may fail if the click is not on a cell, or the //! cell has already been chosen. //! \param click The area clicked on which may be inside a cell. //! \param fill The character ( X or O ) to assign to the cell. //! \return Whether the choice was successfully made. bool makeChoice( const Point & click, const char fill );You are not required to implement the method:
bool isWon() constThis method can potentially give your team extra credit if your team implements the functionality of reporting when a game has been won by one of the players.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Constructors and Destructors ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Default constructor for the TicTacToe class. TicTacToe(); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Accessors ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief draw the components of the TicTacToe class in the drawing area. //! \return Void. void draw() const; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~ Mutators ~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //! \brief Play the game against another person. //! \return Void. void playFriend(); //! \brief Play the game against the computer. void playComputer();You are not required to implement the method:
void playComputer()This method can potentially give your team extra credit if your team implements the functionality to have a user play a computer opponent.
When the game is played, the player(s) should be promted for their name(s), and then each player should take turns choosing cells to fill with their mark ( either X or O ). When it is a players turn to place their mark, they should be prompted to make their choice. Two buttons should also be displayed on the screen. One which allows the players to start a new game, and one which allows them to quit the game.
A framework containing the files and folders you will need can be found here. Download the .tgz file and decompress it in your account using the command:
tar -xzvf <file_name>
For your convienience the Clickable and Button class implementations have been included in the form of ".solution" files.
The public interface of the three classes may not be altered, however, you can do whatever you wish for the private members and private data. The files in the framework contain the declaration of private members and data that you may wish to use, but are not obligated to.
There are two possible ways to recieve extra credit on this lab. One is to implement the "play the computer" functionality, and the other is to make it so the game detects when one of the players has won the game and output the results to the screen.