Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please fix the code in the code notes using the method list & details for the question main code is provided. Java Coding: Methods List:

Please fix the code in the code notes using the method list & details for the question main code is provided.

Java Coding:

Methods List: https://gyazo.com/1654806c406c1732e5603d35301aab6d

Details: https://gyazo.com/904d9207fb81791c2a307d11d70f1b39

Main Code:

public class TicTacToe { // Holds the board contents. Note that the upper left corner // is known as position 1 and the lower right as position 9. // Positions increase by 1 in number from left to right. static String pos1 = "1"; static String pos2 = "2"; static String pos3 = "3"; static String pos4 = "4"; static String pos5 = "5"; static String pos6 = "6"; static String pos7 = "7"; static String pos8 = "8"; static String pos9 = "9"; public static void main(String[] args) { // Variables used for game progress. boolean gameOver = false; String playerTurn = "X"; // Loop until the game is over. while (!gameOver) { // Print the board to the screen. printBoard(); // Get the current player's requested position (1 through 9). int pos = getPosition(); // Places the user's token at the given location. placeToken(pos, playerTurn); // If the last placement either filled the board OR created // a win, then the game is over. if (gameIsOver()) { gameOver = true; } // Task: Change to the next player's turn. // If it was X, it should be come O and vice versa. playerTurn = "Fix Me"; } // If the loop ever exits, it's because the game is over. System.out.println("Thanks for playing!"); } public static boolean gameIsOver() { // Returns true if the board is full OR a player has won. // Returns false, otherwise. return false; // Change this (eventually). } public static void placeToken(int position, String symbol) { // Places a token in the indicated position. } public static int getPosition() { // Requests a valid position from the user. // If the user enters a position that is not between 1 and 9 // OR is already occupied, the user should be informed of the // error and asked again. // Returns the chosen position upon completion. // HINT: Complete the method isAvailable() below and use it to check if the // user gave a valid position. return 0; // Change this (eventually). } public static boolean isAvailable(int position) { // Returns true if the given position is available. return false; // Change this (eventually0. } public static void printBoard() { // Prints the tic-tac-toe board in its current state. // Try to draw this board neatly as a grid (all 9 squares // enclosed by stars, for example). } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

1. In what ways has flexible working revolutionised employment?

Answered: 1 week ago