Home / Expert Answers / Computer Science / using-c-please-separate-code-by-nbsp-in-file-named-tic-tac-toe-h-write-the-class-interface-co-pa739

(Solved): Using C++: Please separate code by:  In file named tic_tac_toe.h, write the class interface co ...



Using C++:

Please separate code by:  In file named tic_tac_toe.h, write the class interface code. In file named tic_tac_toe.cpp, write the class implementation. In file named tic_tac_toe_test.cpp, write the class test cases.In file named main.cpp, run code to play the tic tac to game.

Problem Domain:

The classic TicTacToe game alternatively place Xs and Os on a 3x3 grid. The winner is the first player to place 3 consecutive marks in a horizontal, vertical or diagonal row.

Understanding the Problem:

Update the TicTacToe game to:

1) Determine a winner by row, column, diagonally, or a tie.

2) Display winner of game in main.

3) Update main.cpp game logic to:

     a) Play more than one game

     b) Allow user to quit the game

     c) Display winner of game

 

Understanding the Problem:

A tic tac toe board is usually as follows :

How users see the board:

\begin{tabular}{|l|}
\hline 123 \\
\hline 456 \\
\hline 789 \\
\hline
\end{tabular}

How a programmer sees the board:

\begin{tabular}{|l|l|l|}
\hline 0 & 1 & 2 \\
\hline 3 & 4 & 5 \\
\hline 6 & 7 & 8 \\
\hline
\end{tabular}

In this program, a vector of strings represents the board as follows where value can be " ", O, or X:

Value

 

How to determine if a player has won?

A column wins with marked values 1,4,7 or 2,5,8, or 3,6,9 with all Os or Xs  (Remember a vector index starts at 0)

Example: Win by first column where X goes first

TicTacToe board

\begin{tabular}{|l|l|}
\hline \( \mathrm{X} \) & \( \mathrm{O} \) \\
\hline \( \mathrm{X} \) & \( \mathrm{O} \) \\
\hline \(

 

Vector view (Remember a user will see 1,4 and 7 as a column win.  But the vector will store the values at 0,3, and 6):

 

A row wins with marked values 1,2,3 or 4,5,6 or 7,8,9 with all Os or Xs

A diagonal wins with marked values 1,5,9 or 7,5,3 with all Os or Xs

Class Member Function and Member(variable) Specifications
+ = public  New=new class class function(add it)
- = private 

Update=existing class function(modify it)
NoUpdate=leave class function as is  

Required Test Cases for Assignment 
(write the code in tic_tac_toe_test.cpp)

Green equals new test case
Update=modify existing test case

Main Program Flow

Update the main.cpp program, program continues until user opts out, users can play more than one game, and display the winner of each game.  Add data validation for correct input where required.

In the homeworks folder

    In the tic_tac_toe folder:

    In file named tic_tac_toe.h, write the class interface code.

    In file named tic_tac_toe.cpp, write the class implementation.

    In file named tic_tac_toe_test.cpp, write the class test cases.

    In file named main.cpp, run code to play the tic tac to game.

Running the program from main (write the code in tic_tac_toe/main.cpp)

1) Create a program that will play the TicTacToe game until the user opts to quit (outer loop).

2) Start the game with X or O. Loop here while user doesn’t provide an X or O.

3) Modify (inner loop) that iterates until a winner is determined to display the winner.

4) After a winner is determined prompt user if they want to play another game.

\begin{tabular}{|l|} \hline 123 \\ \hline 456 \\ \hline 789 \\ \hline \end{tabular} \begin{tabular}{|l|l|l|} \hline 0 & 1 & 2 \\ \hline 3 & 4 & 5 \\ \hline 6 & 7 & 8 \\ \hline \end{tabular} Value \begin{tabular}{|l|l|} \hline \( \mathrm{X} \) & \( \mathrm{O} \) \\ \hline \( \mathrm{X} \) & \( \mathrm{O} \) \\ \hline \( \mathrm{X} \) & \\ \hline \end{tabular}


We have an Answer from Expert

View Expert Answer

Expert Answer


Implement the tic tac toe game in c++ programing and implement the desired methods #include #include using namespace std; //Arra
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe