Tie-Tac-Toe Problem Description: Tic Tac Toe game is traditionally played on a 3x3 board bewoen two players x and o. A player can mark a single cell by placing a symbol in it (either an x'or an w character). A player who manages to mark a row, column, or a diagonal completely with his symbol fiest wins the game. The game ends in a tie if no player manages to win after all the cells have boen marked. You will design a textal version of this game, in which a human player gets to play against a computer opponent. Program Specification: In this project, you will implement a complete Tio-Tac-Toe game in a Java program. Your implementation should follow this specification. You may use one or two dimensional amay as data structure for the game bourd. Your program should include the following list of methods: 1. initloard ()- update this method This function initializes the game board. There are 9 cells represenied by 1 oc 2 dimensional amay. 2. gameloard ()- update this method This method prints the game boand. 3. checkWinner ()- update this method This method examines the array to see if either player has won. A player has won if he has marked a row, oolumn or diagonal with his symbol. The fimnction retums different values based on results of winner, loser and no winner. 4. void yourTum() This method handles moves made by the wuser. It displays the game board and asks the user to eater a move. If the move is invalid, in peompts user to eater a valid move again. A valid move sefers to one of the empty cells in the board. 5. void machine lum ) This method handles moves by the oompuler. You can implement a simple logic where you just search for an empty position in the array and mark it for computer player. You can get really creative and design the method so that it makes a well thought out move. The logic is entirely up to you. Finally, you should display the ocomputer's move. 6 main ) The main method controls the game. You will declare an amay for the game and make e of the methods that you have writen to produce behavior of the Tie-Tae-Toe game. The human player always makes the finst move in the game. You should alternate hetwoen the human player and the computer. After each move you should check for a wimer using the checkWinner method. While there is no winner, you should display the penchoard, ak the ser for nest valid mowe, update computer move until one of player wim or the gme is tie. Easy vernsion: human vs. human (machineTum method will he skipped) Challenging version: human vs. smant computer (ie. computer can't he heaten) Sample Output: ter dinate le tahi

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
Question
**Tic-Tac-Toe**

**Problem Description:**

Tic Tac Toe game is traditionally played on a 3x3 board between two players: x and o. A player can mark a single cell by placing a symbol in it (either an 'x' or an 'o' character). A player who manages to mark a row, column, or a diagonal completely with his symbol first wins the game. The game ends in a tie if no player manages to win after all the cells have been marked. You will design a textual version of this game, in which a human player gets to play against a computer opponent.

**Program Specification:**

In this project, you will implement a complete Tic-Tac-Toe game in a Java program. Your implementation should follow this specification. You may use one or two dimensional array as data structure for the game board. Your program should include the following list of methods:

1. **initBoard()** - update this method  
   This function initializes the game board. There are 9 cells represented by 1 or 2 dimensional array.

2. **gameBoard()** - update this method  
   This method prints the game board.

3. **checkWinner()** - update this method  
   This method examines the array to see if either player has won. A player has won if he has marked a row, column, or diagonal with his symbol. The function returns different values based on results of winner, loser and no winner.

4. **void yourTurn()**  
   This method handles moves made by the user. It displays the game board and asks the user to enter a move. If the move is invalid, it prompts user to enter a valid move again. A valid move refers to one of the empty cells in the board.

5. **void machineTurn()**  
   This method handles moves by the computer. You can implement a simple logic where you just search for an empty position in the array and mark it for computer player. You can get really creative and design the method so that it makes a well thought out move. The logic is entirely up to you. Finally, you should display the computer’s move.

6. **main()**  
   The main method controls the game. You will declare an array for the game and make use of the methods that you have written to produce behavior of the Tic-Tac-Toe game. The human player always makes the first move in the game
Transcribed Image Text:**Tic-Tac-Toe** **Problem Description:** Tic Tac Toe game is traditionally played on a 3x3 board between two players: x and o. A player can mark a single cell by placing a symbol in it (either an 'x' or an 'o' character). A player who manages to mark a row, column, or a diagonal completely with his symbol first wins the game. The game ends in a tie if no player manages to win after all the cells have been marked. You will design a textual version of this game, in which a human player gets to play against a computer opponent. **Program Specification:** In this project, you will implement a complete Tic-Tac-Toe game in a Java program. Your implementation should follow this specification. You may use one or two dimensional array as data structure for the game board. Your program should include the following list of methods: 1. **initBoard()** - update this method This function initializes the game board. There are 9 cells represented by 1 or 2 dimensional array. 2. **gameBoard()** - update this method This method prints the game board. 3. **checkWinner()** - update this method This method examines the array to see if either player has won. A player has won if he has marked a row, column, or diagonal with his symbol. The function returns different values based on results of winner, loser and no winner. 4. **void yourTurn()** This method handles moves made by the user. It displays the game board and asks the user to enter a move. If the move is invalid, it prompts user to enter a valid move again. A valid move refers to one of the empty cells in the board. 5. **void machineTurn()** This method handles moves by the computer. You can implement a simple logic where you just search for an empty position in the array and mark it for computer player. You can get really creative and design the method so that it makes a well thought out move. The logic is entirely up to you. Finally, you should display the computer’s move. 6. **main()** The main method controls the game. You will declare an array for the game and make use of the methods that you have written to produce behavior of the Tic-Tac-Toe game. The human player always makes the first move in the game
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Hi I like this code but is it possible to incorportate the 3 methods, because i dont see it in the current code - 

void yourTurn ( ) - This method handles moves made by the user. It displays the game board and asks the user to enter a move.  If the move is invalid, it prompts user to enter a valid move again. A valid move refers to one of the empty cells in the board.

void machineTurn ( ) - This method handles moves by the computer.  One possibility is to search for an empty position in the array and mark it for the computer player

main ( ) - The main method controls the game. You will declare an array for the game and make use of the methods that you have written to produce behavior of the Tic-Tac-Toe game. The human player always makes the first move in the game.  You should alternate between the human player and the computer. After each move you should check for a winner using the checkWinner method. While there is no winner, you should display the gameboard, ask the user for next valid move, update computer move until one of player wins or the game is tie.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Problems on Dynamic Programming
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.
Similar questions
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