Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help me find the errors in this code?? Toe.cpp - X Tiscellaneous Files - (Global Scope) El TicTacToe.cpp: Follow along with the comments

can someone help me find the errors in this code??
image text in transcribed
image text in transcribed
image text in transcribed
Toe.cpp - X Tiscellaneous Files - (Global Scope) El TicTacToe.cpp: Follow along with the comments to create a fully functional Tic Tac Toe game // that uses function calls. Each function will get called multiple times during the execution 1 of the code, however, the code itself only needed to be written once. Also notice the use of 17 an array to store the contents of the board. The comments marked with a TODO denote where code // needs to be added. Buinclude "stdafx.h" #include using namespace std; char boardTile[10] - [ '0', '1 15 // write the function declarations bool checkValid Move(int); void drawBoard(); //TODO: Write the declaration for the function that checks for a winner int main() 19 int player - 1, i, choice; char mark; bool is MoveValid = false; do 1/TODO: Call the function that draws the game board player - (player % 2)? 1 : 2; cout > choice; mark - (player - 1)? 'X':'0'; "; // TODO: Call the checkValidove function, make sure to save the return value in one of the variables if (isMovevalid) { boardTile[choice] - marks elsel cout Game draw: 58 60 61 62 // Check the board for a winner. 1/ Returning 8 -1 is keep playing // Returning a is a draw (or cat wins) // Returning a l shows a winner int checkForwinner() // TODO: Read through the code in this function. Based on the commented rules before the function, determine what type of return statement belongs in each of the comments below. if ((boardTile[1] -- boardTile[2] boardTile(2) - boardTile[9]) Il boardTile[4] - boardTile[5] As boardTile[s] - boardile[6]) 11 (boardTile[7] -- boardTile[8] 8 boardile [8] - boardile[9]) Il boardTile[1] - boardTile[4] 88 boardTile(4) - boardTile[7]) II (boardTile[2] - boardTile[5] 8 boardile(s) - board [8] I! (boardTile[3] - boardTile[6] & boardTile[6] - boardile[]) Il boardTile[1] = boardTile[s] 8 board ile[5] - boardTile ]) II (boardTile[] -- boardTile[5] & boardle[5) -- boarde[2])) Insert return statement else if (boardTile[1] l boardiler 88 boardTile[2] 1 1 boardi[2] '2' & boardTile[5] - "5" 788 boardTile[8] I 3 boardTile[] 1- boardTile[6] - 6 boardTile) ) insert return statement Insert return statement 19 1 Draw the board with the player marks void drawboard) system("cls"); cout O choice using namespace std; char boardTile[10] - [ '0', '1 15 // write the function declarations bool checkValid Move(int); void drawBoard(); //TODO: Write the declaration for the function that checks for a winner int main() 19 int player - 1, i, choice; char mark; bool is MoveValid = false; do 1/TODO: Call the function that draws the game board player - (player % 2)? 1 : 2; cout > choice; mark - (player - 1)? 'X':'0'; "; // TODO: Call the checkValidove function, make sure to save the return value in one of the variables if (isMovevalid) { boardTile[choice] - marks elsel cout Game draw: 58 60 61 62 // Check the board for a winner. 1/ Returning 8 -1 is keep playing // Returning a is a draw (or cat wins) // Returning a l shows a winner int checkForwinner() // TODO: Read through the code in this function. Based on the commented rules before the function, determine what type of return statement belongs in each of the comments below. if ((boardTile[1] -- boardTile[2] boardTile(2) - boardTile[9]) Il boardTile[4] - boardTile[5] As boardTile[s] - boardile[6]) 11 (boardTile[7] -- boardTile[8] 8 boardile [8] - boardile[9]) Il boardTile[1] - boardTile[4] 88 boardTile(4) - boardTile[7]) II (boardTile[2] - boardTile[5] 8 boardile(s) - board [8] I! (boardTile[3] - boardTile[6] & boardTile[6] - boardile[]) Il boardTile[1] = boardTile[s] 8 board ile[5] - boardTile ]) II (boardTile[] -- boardTile[5] & boardle[5) -- boarde[2])) Insert return statement else if (boardTile[1] l boardiler 88 boardTile[2] 1 1 boardi[2] '2' & boardTile[5] - "5" 788 boardTile[8] I 3 boardTile[] 1- boardTile[6] - 6 boardTile) ) insert return statement Insert return statement 19 1 Draw the board with the player marks void drawboard) system("cls"); cout O choice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions