Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that plays a simple game of TicTacToe against a user. The user will input the Xs and the computer will counter

Write a C++ program that plays a simple game of TicTacToe against a user. The user will input the "X"s and the computer will counter with "O"s. The program will update the display after each user input and each computer input. The program will end after someone wins the game (all "X"s or all "O"s in a row) or all 9 spaces are played.

** Below is a screenshot of my main function. I already have this program 99% finished. I am just trying to add User Input Validation. I was thinking about changing my while loop to a do while loop possibly, somewhere between lines 39-41, or maybe using a "try" statement or For Loop? I just need some help tweaking this just a little. The Input Validation should display an error message if the user enters a value other than 0-8 to make a move on the Tic Tac Toe Display, and then re-prompt them to enter a number 0-8. It should say something like: "That Is Not A Valid Move. Please Enter A Number [0-8]. "

image text in transcribed

domanip> E#include 10 11 #include #include #include using namespace std; 14 16 void Display(int]) 17 void compMove(int) 18 char Winner(intl); 19 20 int main) bool playGame true; const int spaces9; int num[spaces] = { -1, -1, -1, -1, -1, -1, .1, -1, -1 }; int x; int numMoves; char input; 24 25 28 while (playGame) 36 31 32 i++) for (int i a; i num[i-1: spaces; while (1) 34 35 36 37 38 39 Display (num) cout input; cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

=+ Are they breakable for any reason?

Answered: 1 week ago

Question

=+When and under what circumstances are contracts renegotiated?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago