Question: the programming language is c++ Problem: Tic Tac Toe Implement the board game Tic Tac Toe according to the following requirements. The program uses a

the programming language is c++

Problem: Tic Tac Toe

Implement the board game Tic Tac Toe according to the following requirements. The program uses a Player struct which holds the name and the mark of a player. Use functions to divide the program into small logical code blocks. The main() function should contain the main game loop and call functions as needed. The program should check for a winner after each turn. The program ends if a player has won or if the board is full. The fields of a board are numbered from1 to 9. The program must perform input validation and prompt the user to re-enter a number if a number other than 1-9 is entered or if a number of a n already occupied field is entered.

Problem 1a Algorithm Design 10 points

Use a top-down design. Break the problem down into functions! Each functions performs a small task. It is much easier to tackle small steps at a time than to come up with the entiresolution at once. Think of small functions as building blocks that you can use later to put the game flow together.

List all functions as a commented bulleted list, such as:

/*-function 1

-function 2

-

....

*/

Once you have identified all functions, design the algorithm for the game. Write pseudo code a bove the program as a comment. Each line should hold a single statement. Do not write C++ code yet but instead simple commands. Utilize the functions you identified in part 1

./*

prompt for input

validate input (x > 1)

loop until condition is false:

etc.

*/

Problem 1b Implementation:

Implement the algorithm you developed in problem 1a in C++. You may only use the following library functions of #include: isupper(x), islower(x), isalpha(x)

Hint: Use a player pointer as the current player and point it to player 1 or player 2 after each turn. This will help you keep your code clean and reduce the number of conditions need to check whose turn it is.

Example:

Name for player 1: Tic

Choose a mark (A-Z): Z

Name for player 2: Tac

Choose a mark (A-Z): M

Tic starts.

Tic's (Z) turn

[1][2][3]

[4][5][6]

[7][8][9]

Select a field (1-9): 1

Tac's (M) turn

[Z][2][3]

[4][5][6]

[7][8][9]

Select a field (1-9): 50

Select a field (1-9): 5

Tic's (Z) turn

[Z][2][3]

[4][M][6]

[7][8][9]

Select a field (1-9): 3

Tac's (M) turn

[Z][2][Z]

[4][M][6]

[7][8][9]

Select a field (1-9): 2

Tic's (Z) turn

[Z][M][Z]

[4][M][6]

[7][8][9]

Select a field (1-9): 4

Tac's (M) turn

[Z][M][Z]

[Z][M][6]

[7][8][9]

Select a field (1-9):8

Tac is the winner !

[Z][M][Z]

[Z][M][6]

[7][M][9]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!