Question
(C++) Please create a tic tac toe game. Must write a Player class to store each players information (name and score) and to update their
(C++) Please create a tic tac toe game. Must write a Player class to store each players information (name and score) and to update their information (increase their score if appropriate) and to retrieve their information (name and score).The players must be called by name during the game. The turns alternate starting with player 1 in the first move of round 1. Whoever plays last in a round will play second in the next round (assuming there is one).The rows must be numbered 1 to 3, and also the columns. The user will always enter the position of choice by entering two numbers with spaces between them.You can assume the user always enters a valid pair of numbers (within the 1-3 range) and will always select an open position (but it would be a good exercise to write code to test against this).
1. Write the Player class first. Make sure you can create instances of the class, call its member functions, and that those member functions work correctly.
2. Using a std::vector variable, create a representation of an empty game board with only the numbers 1-3, pipes, and dashes, but no xs or os.
Each row will be one of the std::strings stored in the vector.
3. Write a loop that will print the empty board.
4. Write code that will prompt a user for a desired coordinate and update the variable to have an x at that position. Check it works by printing the board.Sample output:
This is a Tic Tac Toe game!
Please enter the name of player 1: [USER ENTERS A NAME]
Thanks. Please enter the name of player 2: [USER ENTERS A NAME]
How many rounds would you like to play? [USER ENTERS A NUMBER]
Let the game begin!
//This will be repeated while the number of rounds played has not exceeded the number of rounds chosen
//This will be repeated each round until one of the players has 3 in a row, 3 down, 3 in a diagonal, or the board is full.
//Board is displayed in a table format with pipes (|) and dashes (-), with 1 2 3 indicating row and column, and with player 1 represented by xs and player 2 by os. See display*** It is [THE CORRECT PLAYERS TURN].
Where would you like to play? Enter your row position and column position: row col: [USER ENTERS ROW NUMBER SPACE A COLUMN NUMBER]
//After the selection, the users token should be placed at the square and the board should be displayed again
//The board should be displayed after the round is over and a message (however you wish to convey the message) should say who won the round or state there was a draw if all 9 squares were filled but no one won; it should then give a summary of the current number of points each player has. The winning player should have their score increased by 1 and if there is a draw then neither player is awarded a point.
//When all the rounds have been played, there should be a final recap of the number of points and who the winner was (or state there was a draw if there was a tie in the scores)*
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started