Lab 4 : Tic-Tac-Toe

June 29, 2020
Instructions:

Log in to your Zybooks account. Open the lab 4, found in section 4.31.   Edit and run your program in "Develop Mode", and then switch to "Submit Mode" when you want to run the official tests.

What you will Need to Do:

You have been given part of the code (in main() and some function declarations) but will need to add code in several functions to implement the game of Tic-Tac-Toe. The starting point for this lab exercise can be found in section 4.31 of Zybooks.
In order to make things easier, just for this program, we will use global variables, even though using global variables in your programs is strongly discouraged and usually will lead to point deductions.

Do not edit the code in main(). The code in main() calls various functions.  You must complete the code in these functions so that the game works properly.


Level 1:  (1 Point)
Complete the function displayBoard(). It should use the board variables to display the board.

Level 2:  (1 Point)
Complete the function makeMove() which allows the user to make a move.  It should prompt for user input, read in the user input number, and change to appropriate board variable.

Level 3: (Extra Credit, 1 Point)
Complete the checkBoard() function that checks for a win after every turn.  A win can be three of the same kind on any row, column, or diagonal.


The game starts by player 'X' selecting a move position. Players alternate on every move, until someone wins (with three in a row) or the board is filled and the game is a draw.  Running the program should look like the following, where user input is shown below in bold:


Welcome to the TicTacToe game!
Take turns entering the position (1..9)
into which your piece will be placed.
Enter '0' (zero) to exit.

-------
| | | |   1  2  3
-------
| | | |   4  5  6
-------
| | | |   7  8  9
-------

1. Enter the move (1..9) for X: 1

-------
|X| | |   1  2  3
-------
| | | |   4  5  6
-------
| | | |   7  8  9
-------

2. Enter the move (1..9) for O: 3

-------
|X| |O|   1  2  3
-------
| | | |   4  5  6
-------
| | | |   7  8  9
-------

3. Enter the move (1..9) for X: 4

-------
|X| |O|   1  2  3
-------
|X| | |   4  5  6
-------
| | | |   7  8  9
-------

4. Enter the move (1..9) for O:

-------
|X| |O|   1  2  3
-------
|X| | |   4  5  6
-------
|O| | |   7  8  9
-------

5. Enter the move (1..9) for X: 5

-------
|X| |O|   1  2  3
-------
|X|X| |   4  5  6
-------
|O| | |   7  8  9
-------

6. Enter the move (1..9) for O: 6

-------
|X| |O|   1  2  3
-------
|X|X|O|   4  5  6
-------
|O| | |   7  8  9
-------

7. Enter the move (1..9) for X: 9

-------
|X| |O|   1  2  3
-------
|X|X|O|   4  5  6
-------
|O| |X|   7  8  9
-------

Congratulations player X. You WON!
Exiting program...