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:
How a programmer sees the board:
In this program, a vector of strings represents the board as follows where value can be " ", O, or X:
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
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.