Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task You will create a game Tic-Tac-Toe for two players. One player places the X pieces and the other player places the O pieces. The

Task

You will create a game Tic-Tac-Toe for two players. One player places the X pieces and the other player places the O pieces. The basic game board is a grid of 9 spaces, in a 3 x 3 arrangement. When one player covers an entire row, column or diagonal, the player wins the game.

In this program, you will design a class TicTacToe with appropriate-designed data fields and member functions for the game. Your program will

  • Allow two users to play Tic-Tac-Toe
  • Display the board
  • Allow users to place pieces (X or O) by taking turns (Note: If a space is taken by a player, the other player cannot place a piece in that space.)
  • Check for a winner

Comments:

  • The board, with the actions that can be taken on it, will be in the TicTacToe class.
  • The board should be displayed after each turn. Empty (available) spaces should appear blank. Used spaces should have the appropriate character (X or 0) in them.
  • Users should indicate where to place their pieces by using a number for row and a number for column (the row number and the column number in the grid start from 1, not 0).
  • Users may place pieces only in empty spaces check before you place the piece.
  • You may choose to require X or 0 to start or you may leave the choice to the users, but you must enforce the alternating turns.
  • The game ends as soon as a player has filled one row or one column or one full diagonal.

A sample output is shown below.

image text in transcribed

You must submit three files:

  • The header file: TicTacToe.h
  • The implementation file: TicTacToe.cpp
  • The driver program: TicGame.cpp
1 encer your YON: 1 enter your column ] . [*] . . Player - - :- - --- 1 encer your column Player 3 : : : - - --- - -- - ] [ [ x x ] ] ] Playas O - : - - : - -- - ] ] : = = = = : --- ] ) ] ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions