C++ Code Design( Pseudocode and Code) Design a program that allows two players t
ID: 3761437 • Letter: C
Question
C++ Code Design( Pseudocode and Code)
Design a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional String array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that does the following:
a. Displays the contents of the board array.
b. Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and column number.
c. Allows player 2 to select a location on the board for an O. The program should ask the user to eter the row and column number.
d. Determines whether a player has won or if a tie has occurred. If a player has won, the program should declare that player the winner and end. If a tie has occurred, the program should say so and end.
e. Player 1 wis when there are three X's in a row on the game board. Player 2 wins when there are three O's in a row on the game board. The winning X's or O's can appear in a row, in a column, or diagonally across the board. A tie occurs when all of the locations on the board are full, but there is no winner.
Explanation / Answer
//-------------------START OF ACTION PERFORMED CLASS-------------------------// public void actionPerformed(ActionEvent click) { Object source = click.getSource(); for(int i=1; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.