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
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