Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

2. Define identity.

Answered: 1 week ago

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago