// play game until game Over is true start with player 'X' while (!gameOver) { // get current player choice, and update board value // display the updated board // switch player 'X' -> '0' or '0' -> 'X' // check for winner, draw or game is not over yet } tasks: =========== You need to complete the following methods receiveUserChoice () isGameOver()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Tic tac game in JAVA

Using one dimensional array to implement Tic-Tac-Toe Game.
Tic-Tac-Toe Game Outline:
=========
// play game until game Over is true
start with player 'X'
while (!gameOver) {
// get current player choice, and update board value
// display the updated board
=======
// switch player 'X' -> '0' or '0' -> 'X'
// check for winner, draw or game is not over yet
}
tasks:
===========
You need to complete the following methods
receiveUserChoice ()
isGameOver()
Transcribed Image Text:Using one dimensional array to implement Tic-Tac-Toe Game. Tic-Tac-Toe Game Outline: ========= // play game until game Over is true start with player 'X' while (!gameOver) { // get current player choice, and update board value // display the updated board ======= // switch player 'X' -> '0' or '0' -> 'X' // check for winner, draw or game is not over yet } tasks: =========== You need to complete the following methods receiveUserChoice () isGameOver()
write a program that will allow two users to play
tic-tac-toe. The program should ask for moves alternately from player X and player O. The program displays the game
positions as follows:
1
1
4
7
4
1
4
7
4
1
7
1
X's turn (enter position number):
Once X enters (in this case 2), then the board displays X at that position and asks for next input (from O):
1
3
2
4
5
4
8
7
4
7
X
5
8
7
Your program should check if the user entered a valid position. A position can be invalid if:
1)
User enters a number less than 1 or greater than 10 i.e., the position number does not exist
2) A user has already selected the position. For example in the above case, selecting 2 would be invalid after X's
move because X selected 2 in the first round.
X
5
O's turn (enter position number):
The player O enters 3, then it will show like below;
1
In both these cases, the program should ask the user to enter a valid position. For example, say you have this
board:
8
X
5
7 8
8
X
X
3
X's turn (enter position number): 2
Invalid position. Enter a valid position.
X's turn (enter position number):
6
X
9
X
6
9
X
X
O
X
6
9
Program ends when there is no place to enter, or a winner is decided. A winner is someone who has 3 places
in a row (horizontally, vertically, or diagonally). Your program should check if there is a winner after each user's
input and announces a winner when it detects one.
O's turn (enter position number):
0
6
9
O
6
X's turn (enter position number): 8
9
8 9
0
O
0
6
9
***** X WINS !!! *****
Transcribed Image Text:write a program that will allow two users to play tic-tac-toe. The program should ask for moves alternately from player X and player O. The program displays the game positions as follows: 1 1 4 7 4 1 4 7 4 1 7 1 X's turn (enter position number): Once X enters (in this case 2), then the board displays X at that position and asks for next input (from O): 1 3 2 4 5 4 8 7 4 7 X 5 8 7 Your program should check if the user entered a valid position. A position can be invalid if: 1) User enters a number less than 1 or greater than 10 i.e., the position number does not exist 2) A user has already selected the position. For example in the above case, selecting 2 would be invalid after X's move because X selected 2 in the first round. X 5 O's turn (enter position number): The player O enters 3, then it will show like below; 1 In both these cases, the program should ask the user to enter a valid position. For example, say you have this board: 8 X 5 7 8 8 X X 3 X's turn (enter position number): 2 Invalid position. Enter a valid position. X's turn (enter position number): 6 X 9 X 6 9 X X O X 6 9 Program ends when there is no place to enter, or a winner is decided. A winner is someone who has 3 places in a row (horizontally, vertically, or diagonally). Your program should check if there is a winner after each user's input and announces a winner when it detects one. O's turn (enter position number): 0 6 9 O 6 X's turn (enter position number): 8 9 8 9 0 O 0 6 9 ***** X WINS !!! *****
Expert Solution
steps

Step by step

Solved in 4 steps with 8 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education