In: Computer Science
C++
The program will call the start_game function with argument O or
X to indicate first player and will keep track of the next player
while players take turns marking the board until the board is full.
This version of the game only plays one game.
Class Specifications
TicTacToe class does not have a
constructor.
Member Functions and Member(variable)
Specifications
+ = public
- = private
public/private |
New /Update/NoUpdate |
Function/Data Member |
Functionality of function or data member |
|
+ |
New |
bool game_over |
No parameters |
|
+ |
Update |
void start_game(string first_player) |
1) first_player function argument value must be X or O;
otherwise, throw an Error exception when value is not X or O. Error
Message: Player must be X or O. |
|
+ |
void mark_board(int position) |
1) Value of int must be in the range 1 to 9; otherwise, throw an
Error exception if value not in this range. Error Message: Position
must be 1 to 9. |
||
+ |
string get_player() const |
Return the next_player value |
||
+ |
New |
void display_board const |
No parameters |
|
private functions |
||||
- |
void set_next_player() |
Set next_player. If private variable player X, player is O else player is X |
||
- |
New |
void check_board_full |
No parameters |
|
- |
New |
void clear_board const |
No parameters |
|
Class private Data |
||||
- |
string player |
Class member variable |
||
New |
vector of string pegs |
Class member variable |
||
UNIT TEST CASES
Required Test Cases for Assignment (write the code in
/homeworks/tic_tac_toe_test/ tic_tac_toe_test.cpp)
Test Case Name |
Steps to Test |
Test Mark Position accepts values from 1 to 9 only |
1) Create an instance of TicTacToe game |
Test game over if 9 slots are selected. |
1)Create an instance of TicTacToe game |
I develop code different way please see
first import header file , create global variable
function to show the current status of the gaming board
function name is display_board()....
function to get the player input and update the board
function name is player_turn().....
continue above function
function to get the game status e.g. GAME WON, GAME DRAW, GAME IN CONTINUE MODE
function name is gameover()....
main method...
output view
GAME DRAW
GAME WON
crazy code......!!