Create an interactive JAVA program (A human player vs computer) Tic Tac Toe game
ID: 3766057 • Letter: C
Question
Create an interactive JAVA program
(A human player vs computer) Tic Tac Toe game.
Follow these instructions for the entire program
Explain your program with comments
Ask the user to play again until user answers “NO”
The file “game_log.txt does not have to be created first. Let the program create this file.
The game board does not have to print the Tic TAC Toe table
Use: do-while loop, nest loops, enhanced for loops, Boolean Operators
Player should be able to pick between an ‘’x’’ or ‘’o’’
The program should print an empty board, with numbers representing each playable position:
1 2 3
4 5 6
7 8 9
The user should provide the number representative of the position where the user would like to place their letter of choice. Handle scenarios where the user chooses a position that is not available.
Once the user input is received, then the program should place the opposing letter in an available position.
The game should continue until
The player wins by connecting three in a row either horizontally, vertically or diagonally (Print “You win!”)
The player loses if the program connects three in a row either horizontally, vertically or diagonally. (Print “Better luck next time.”)
The game is a draw if all playable spaces are filled but neither connects three in a row. (Print “draw!”)
After each move the game should be printed so that the player knows what the game board looks like after each play.
After each move the game board should be written to a file named “game_log.txt”, which records all game activity
After the game ends, the program should ask the user to play again.
If “yes” then a new game begins
If “no” then print:
The number of games played.
The number of wins, losses and draws.
The player’s winning percentage. [Winning percentage= (#of games won/# of games played)*100]
Print “thanks for playing!”
Close file.
The program should handle potential exceptions that may be thrown by using try/catch.
Explanation / Answer
Create an interactive JAVA program (A human player vs computer) Tic Tac Toe game
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.