Write a modular program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array w three rows and three columns as the game board. Each element of the array should be initialized with an asterisk ( 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 and column number. Then redisplay the board wit an X replacing the * in the chosen location. • 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 r and column number. Then redisplay the board with an O replacing the * in the chosen location. The loop should continue until a player has won or a tie has occurred, then display a message indicating who won, 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).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Could this be done in C++  please?

1.

  • The class should have a two dimensional array of the char or int type as a private variable. 
  • The class could have some other private variables as needed. 
  • A public constructor must should be used to initialize private variables. 
  • Remember that you need two loops to access all rows and columns to initialize each array element.
  • There must be other public functions to do tasks, such as XPlay, OPlay, DetermineAWinner, and others as needed. 

2.

The main should have a loop to repeat tasks until there is a winner or a tie.

 

Write a modular program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array w
three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (
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 and column number. Then redisplay the board wit
an X replacing the * in the chosen location.
• 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 r
and column number. Then redisplay the board with an O replacing the * in the chosen location.
The loop should continue until a player has won or a tie has occurred, then display a message indicating who won,
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).
Transcribed Image Text:Write a modular program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array w three rows and three columns as the game board. Each element of the array should be initialized with an asterisk ( 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 and column number. Then redisplay the board wit an X replacing the * in the chosen location. • 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 r and column number. Then redisplay the board with an O replacing the * in the chosen location. The loop should continue until a player has won or a tie has occurred, then display a message indicating who won, 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).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education