Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CS 210 Assignment 2 Due Date: Oct.10/2017 In this human-vs-human, human-vs-computer, or computer-vs-computer you will implement a simple Tic-Tac-Toe game. It will be possible to
CS 210 Assignment 2 Due Date: Oct.10/2017 In this human-vs-human, human-vs-computer, or computer-vs-computer you will implement a simple Tic-Tac-Toe game. It will be possible to pay Tic-Tac-Toe, also called X's and O's, Noughts and Crosses, and X and 0 is a simple game played on a 3x3 grid, referred to as the board. The grid starts enpty, and the two payers take turns placing their respective symbols, Xand O, on an empty grid cell, referred to as making a move The first payer to get a straight line of three symbols wins. If all the cells on the board are filled and neither player has a line of3 symbols, the game is a tie. Lines may be horizontal vertical, or diagonal You will implement a Board cass to represent the 3x3 grid. This class will have functions to determine which symbol if any, is in a cell to place a symbol in a cell to determine the winner if any so far, and to print the board to standard output The board should appear as below: You will implement an abstract Player cass to determine the payer's moves. The Player class should store which symbol it will place and contain a pure virtual function to determine the Player's next move. This function will be overridden by the subclasses of Player You will implement ?layerHuman as a subclass of Player. When this subclass is to choose a move, it should print ot the curent board and ask the user for the row and co lumn to pace a symbol This cass should detect if the user enters an invalid location, either because it is not in the grid or it aready has a symbol and if the location is invalid, ask the user again You will implerent ?layerRandom as a subclass ofPlayer. When this subclass is to choose a move, it should return a random position in the grd that does not yet have a symbol You will impleent a program to play the Tic Tac Toe game. The program should begin by asking the user if each team should be controlled by a human or by the computer. The program should then use dynamic memory allocation to create instances ofthe appropriate subclasses of Player. These ust be stored with pointers of type Player*. The first team should phce x symbols, while the second teamshould pace O symbols. The program should then alternate asking the players for moves until one player wins, or the board is full and the game is a tie Afer the game is over, the program should print the winner and the board and exit CS 210 Assignment 2 Due Date: Oct.10/2017 In this human-vs-human, human-vs-computer, or computer-vs-computer you will implement a simple Tic-Tac-Toe game. It will be possible to pay Tic-Tac-Toe, also called X's and O's, Noughts and Crosses, and X and 0 is a simple game played on a 3x3 grid, referred to as the board. The grid starts enpty, and the two payers take turns placing their respective symbols, Xand O, on an empty grid cell, referred to as making a move The first payer to get a straight line of three symbols wins. If all the cells on the board are filled and neither player has a line of3 symbols, the game is a tie. Lines may be horizontal vertical, or diagonal You will implement a Board cass to represent the 3x3 grid. This class will have functions to determine which symbol if any, is in a cell to place a symbol in a cell to determine the winner if any so far, and to print the board to standard output The board should appear as below: You will implement an abstract Player cass to determine the payer's moves. The Player class should store which symbol it will place and contain a pure virtual function to determine the Player's next move. This function will be overridden by the subclasses of Player You will implement ?layerHuman as a subclass of Player. When this subclass is to choose a move, it should print ot the curent board and ask the user for the row and co lumn to pace a symbol This cass should detect if the user enters an invalid location, either because it is not in the grid or it aready has a symbol and if the location is invalid, ask the user again You will implerent ?layerRandom as a subclass ofPlayer. When this subclass is to choose a move, it should return a random position in the grd that does not yet have a symbol You will impleent a program to play the Tic Tac Toe game. The program should begin by asking the user if each team should be controlled by a human or by the computer. The program should then use dynamic memory allocation to create instances ofthe appropriate subclasses of Player. These ust be stored with pointers of type Player*. The first team should phce x symbols, while the second teamshould pace O symbols. The program should then alternate asking the players for moves until one player wins, or the board is full and the game is a tie Afer the game is over, the program should print the winner and the board and exit
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started