This must be in C++     You have decided to use your skills to develop a program that will allow you to enjoy a few minutes of game playing at work. You review a list of your favorite games from your childhood and remember how much you loved tic-tac-toe. You believe that it will be a relatively easy program to develop so you jump on it. Write a program that allows two players to play the game. Use a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). I STRONGLY recommend you write a function that accepts the two-dimensional array as one of its arguments. This function will display the contents of the two dimensional array. Call this function each time you need to display (or re-display) the contents of the array. The program should display the initial board configuration and then start a loop that does the following: Have player 1 select a board location for an "X" by entering a row number and a column number. Then clear the screen (suing the clearscreen function I emailed to each of you), redisplay the board with an "X" replacing the * in the chosen location. After each move (starting with the fifth legal move of the game), the program will call a function to determine if there is a winner for the game by passing the two-dimensional array into the function and returning who the winner is (should return a string). This function will be called starting with the 5th legal move through legal move #9 OR a winner has been declared. If there is no winner yet and the board is not yet full, have player 2 select a board location for an "O" by entering a row and a column number. Then clear the screen (using the clearscreen function I sent you), redisplay the board with an "O" replacing the * in the chosen location. The loop should continue until either a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. Player 1 wins when there are three "Xs" in a row, a column, or a diagonal on the game board. Player 2 wins when there are three "Os" in a row, a column, or a diagonal on the game board. A tie occurs when all of the locations on the board are full, but there is no winner. Input validation: Only allow legal moves to be entered. The row and column must be 1,2 or 3. The selected board location MUST currently be empty (i.e., still have an asterisk in it). If it is not available, then a message should be displayed that the selected position is not available AND allow the user to re-enter a new board location. Your program SHOULD NOT go back to the other player. For example, if Player 2 chooses an incorrect location (one already taken), then Player 2 must be given a chance to choose another valid position until they choose an available position.

Oh no! Our experts couldn't answer your question.

Don't worry! We won't leave you hanging. Plus, we're giving you back one question for the inconvenience.

Submit your question and receive a step-by-step explanation from our experts in as fast as 30 minutes.
You have no more questions left.
Message from our expert:
Our experts are unable to provide you with a solution at this time. Try rewording your question, and make sure to submit one question at a time. We've credited a question to your account.
Your Question:

This must be in C++

 

 

  1. You have decided to use your skills to develop a program that will allow you to enjoy a few minutes of game playing at work. You review a list of your favorite games from your childhood and remember how much you loved tic-tac-toe. You believe that it will be a relatively easy program to develop so you jump on it.

    Write a program that allows two players to play the game. Use a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). I STRONGLY recommend you write a function that accepts the two-dimensional array as one of its arguments. This function will display the contents of the two dimensional array. Call this function each time you need to display (or re-display) the contents of the array. The program should display the initial board configuration and then start a loop that does the following:

    • Have player 1 select a board location for an "X" by entering a row number and a column number. Then clear the screen (suing the clearscreen function I emailed to each of you), redisplay the board with an "X" replacing the * in the chosen location.
    • After each move (starting with the fifth legal move of the game), the program will call a function to determine if there is a winner for the game by passing the two-dimensional array into the function and returning who the winner is (should return a string). This function will be called starting with the 5th legal move through legal move #9 OR a winner has been declared.
    • If there is no winner yet and the board is not yet full, have player 2 select a board location for an "O" by entering a row and a column number. Then clear the screen (using the clearscreen function I sent you), redisplay the board with an "O" replacing the * in the chosen location.

    The loop should continue until either a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred.

    • Player 1 wins when there are three "Xs" in a row, a column, or a diagonal on the game board.
    • Player 2 wins when there are three "Os" in a row, a column, or a diagonal on the game board.
    • A tie occurs when all of the locations on the board are full, but there is no winner.

    Input validation: Only allow legal moves to be entered. The row and column must be 1,2 or 3. The selected board location MUST currently be empty (i.e., still have an asterisk in it). If it is not available, then a message should be displayed that the selected position is not available AND allow the user to re-enter a new board location. Your program SHOULD NOT go back to the other player. For example, if Player 2 chooses an incorrect location (one already taken), then Player 2 must be given a chance to choose another valid position until they choose an available position.

Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,