Question: Write a Tic-Tac-Toe game. When run first print 3 rows of underscore separated with spaces. Print a message ask the player O to enter two

Write a Tic-Tac-Toe game. When run first print 3 rows of underscore separated with spaces. Print a message ask the player O to enter two numbers range from 1 to 3 separated by a space for his or her move. After read in the two numbers, print the same three rows again with the location O entered replaced with letter O. Print the same message asking the player X to enter two numbers for his or her move and then print the 3 rows again with the location X entered replace with letter X.

The program has to be able detected if one entered a location already take and ask him or her to enter again until it's a empty location.

The program also needs to be able to detect if someone win the game (form a line of his or her pieces) and announce it.

Following is the example outputs.

_ _ _

_ _ _

_ _ _

Player O, please enter your move (two numbers (1-3) separated by a space): 2 2

_ _ _

_ O _

_ _ _

Player X, please enter your move (two numbers (1-3) separated by a space): 1 1

X _ _

_ O _

_ _ _

using esclipe ide java script

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!