Question: Overview The program will welcome the user and ask if they would like to play a game. If they answer yes, the program will ask
Overview The program will welcome the user and ask if they would like to play a game. If they answer yes, the program will ask the user who should go first, the computer or the human. Taking this into account the program will alternate computer and human player moves until one of three situations occur: 1. There are three Xs in a row on the board. In this case, the computer wins since for our program, the computer always plays X. 2. There are three Os in a row on the board. In this case, the human wins since for our program, the human always plays O. 3. All of the positions have an X or an O, but the same symbol does not occur three in a row on the board. This is a tie. Once one of these situations occurs, the game is over and the program displays the result. The program will then ask the user if they want to play again. If they answer yes, the game process starts anew. If they answer no, the program bids farewell to the user and ends. Writing the Program A program skeleton (TicTacToeStarter.java) has been provided to help you write your program. The skeleton includes two class variables that are visible to all of the programs methods: a Scanner used to read user input from the keyboard and a char array of size nine used to represent the tic tac toe board. In all, the program consists of eleven methods: main, playGame, initializeGameBoard, processComputerMove, processHumanMove, displayGameBoard, isDone, isComputerWin, isHumanWin, isPlayerWin, and isTie. A few of these already have some code in them, but most dont. All of them contain instructions on what you need to do in these methods. Your job is to complete all of the missing code. In some cases you can write the code as you want, but in others you are provided with some information about what you need to do. Ultimately, your program should work in a fashion similar to what is presented in the Sample Run sections below. For your implementation, you should rename the file TicTacToeStarter.java to TicTacToe.java.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
