The code and the output Console Shell Instructions 1. Create a TicTacToe class 2. Declare 2D array
Fantastic news! We've Found the answer you've been seeking!
Question:
The code and the output
Transcribed Image Text:
Console Shell Instructions 1. Create a TicTacToe class 2. Declare 2D array as an instance variable representing the grid and a integer instance variable to represent who's turn it is. 3. Create a constructor that initializes the 2D array with the "-" value for all the items in the array. Also initialize the turn variable. 4. Create a print() method to print all the items in the 2D array separated by a space. 5. In Main, create a TicTacToe object and call print you can see the grid with all "-". 6. Ask for first player's name and second player's name and store those values Part 2: Methods 1. checkLocation(int row, int col) - This method returns a boolean value that determines if the spot a user picks to put their piece is valid. A valid space is one where the row and column are within the size of the board, and there are no X or O values currently present. take screenshot demonstrating that the method works and post on canvas 2. take Turn(int row, int col) - This method adds an X or O to the array at position row,col depending on whose turn it is. If it's an even turn, X should be added to the array, if it's odd, O should be added. It also adds one to the value of turn. take screenshot demonstrating that the method works and post on canvas 3. checkWin(String xo) - This method returns a boolean that determines if a user has won the game. This method uses three methods to make that check: . checkCol(String xo) This checks if a player has three X or O values in a single column, and returns true if that's the case. - checkRow(String xo) This checks if a player has three X or O values in a single row. checkDiag(String xo) - This checks if a player has three X or O values diagonally. checkWin(String xo) only returns true if one of these three checks is true. take screenshot demonstrating that the method works and post on canvas Part 3: Game Play Complete game play in Main.java ask user for row and col. only continue if given acceptable values. place X or O accordingly and check for a winner. player 2 should not get a turn if the game is won by player 1 Screenshot player 1 winning, player 2 winning, and a tie. Console Shell Instructions 1. Create a TicTacToe class 2. Declare 2D array as an instance variable representing the grid and a integer instance variable to represent who's turn it is. 3. Create a constructor that initializes the 2D array with the "-" value for all the items in the array. Also initialize the turn variable. 4. Create a print() method to print all the items in the 2D array separated by a space. 5. In Main, create a TicTacToe object and call print you can see the grid with all "-". 6. Ask for first player's name and second player's name and store those values Part 2: Methods 1. checkLocation(int row, int col) - This method returns a boolean value that determines if the spot a user picks to put their piece is valid. A valid space is one where the row and column are within the size of the board, and there are no X or O values currently present. take screenshot demonstrating that the method works and post on canvas 2. take Turn(int row, int col) - This method adds an X or O to the array at position row,col depending on whose turn it is. If it's an even turn, X should be added to the array, if it's odd, O should be added. It also adds one to the value of turn. take screenshot demonstrating that the method works and post on canvas 3. checkWin(String xo) - This method returns a boolean that determines if a user has won the game. This method uses three methods to make that check: . checkCol(String xo) This checks if a player has three X or O values in a single column, and returns true if that's the case. - checkRow(String xo) This checks if a player has three X or O values in a single row. checkDiag(String xo) - This checks if a player has three X or O values diagonally. checkWin(String xo) only returns true if one of these three checks is true. take screenshot demonstrating that the method works and post on canvas Part 3: Game Play Complete game play in Main.java ask user for row and col. only continue if given acceptable values. place X or O accordingly and check for a winner. player 2 should not get a turn if the game is won by player 1 Screenshot player 1 winning, player 2 winning, and a tie.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Has Mississippi enacted the Uniform Real Property Electronic Recording Act? Provide the URL/web address of your source. Provide the citation to where this law is found in the Miss. Code (including...
-
A firm's total cost is $1,000 if it produces one unit, $1,600 if it produces two units, and $2,000 if it produces three units of output. Draw up a table of total, average, and marginal costs for this...
-
After examining the opportunity set you realize that you can invest in a portfolio consisting of the bond fund and the large-cap stock fund that will have exactly the same standard deviation as the...
-
Scientists at NASA collected data to study which forces, including both natural and human factors, are responsible for the increase in observed temperature in the last two centuries. Go to http://www...
-
Prepare journal entries to record the following. (a) Perez Company retires its delivery equipment, which cost $44,000. Accumulated depreciation is also $44,000 on this delivery equipment. No salvage...
-
Allocating product costs between ending inventory and cost of goods sold. Solomon Manufacturing Company began operations on January 1 . During the year, it started and completed 1 , 6 2 0 units of...
-
Ten pounds of CO 2 at room temperature (80 F) are stored in a fire extinguisher that has a volume of 4.0 ft 3 . How much heat must be transferred from the extinguisher so that 40 % of the CO 2...
-
Provide a brief history of Mississauga, Ontario, Canada on the First Peoples territory. What was Mississauga called before it was given a European name? Is there a treaty and if so, who were the...
-
The financial information in the Excel file associated with this exercise was obtained from Form 10-K reports for Costco Wholesale Corporation . In this exercise, we examine how changing the starting...
-
PLEASE WRITE CREATE AN ANNOTATION FROM THE FOLLOWING: RELIGIONS HELP US FORM THE BASIC ASSUMPTIONS ABOUT WHO WE ARE AND HOW WE SHOULD ACT IN THE WORLD. PRESENTLY, TWO WORLDVIEWS WITH ACCOMPANYING...
-
MCI Board Analysis This time, you are on the internal side of the board meeting. As the CFO of MCI, and you must prepare a proposal for discussion at the next meeting of the board of directors. Based...
-
Automatic round the clock tellers are the newest thing in the banking industry. Several companies have developed these computerized money machines and are bombarding bank managers with sales people...
-
Answer two discussion questions: 1. Analyze how man's selfish desires are part of the dramatic monologues. 2. How is nature depicted in this weeks poetry? Choose two poems from this week and analyze...
-
In Exercises discuss the continuity of each function. f(x) -3 1 x - 4 y 3 2 -1 -2 -3+ 3 X
-
Financial items for George Karatsis IT Services on 31 May 2024 are presented below in alphabetical order. Required (a) Prepare a statement of financial position similar to the one in figure 2.2. (b)...
-
During the year ended 30 June 2024, Skilled Services, a provider of temporary secretary personnel, had collected receipts from clients for a total value of \($250000.\) Wages of \($136000\) had been...
-
Rebecca Tallance operates a rent a dress business from her home. She keeps her accounting records for business activities completely separate from her records for personal activities. At 30 June...
Study smarter with the SolutionInn App