For this exercise, you will complete the TicTacToe Board that we started in the 2D Arrays Lesson.

We will add a couple of methods to the TicTacToe class.

To track whose turn it is, we will use a counter turn. This is already declared as a private instance variable.

Create a getTurn method that returns the value of turn.

Other methods to implement:

printBoard()- This method should print the TicTacToe array onto the console. The board should include numbers that can help the user figure out which row and which column they are viewing at any given time. Sample output for this would be:

0 1 2
0 - - -
1 - - -
2 - - -
pickLocation(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.
takeTurn(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.
checkWin()- This method returns a boolean that determines if a user has won the game. This method uses three methods to make that check:

checkCol- This checks if a player has three X or O values in a single column, and returns true if that’s the case.
checkRow - This checks if a player has three X or O values in a single row.
checkDiag - This checks if a player has three X or O values diagonally.
checkWin() only returns true if one of these three checks is true.

public class TicTacToeTester
{
public static void main(String[] args)
{
//This is to help you test your methods. Feel free to add code at the end to check
//to see if your checkWin method works!
TicTacToe game = new TicTacToe();
System.out.println("Initial Game Board:");
game.printBoard();

//Prints the first row of turns taken
for(int row = 0; row < 3; row++)
{
if(game.pickLocation(0, row))
{
game.takeTurn(0, row);
}
}
System.out.println("\nAfter three turns:");
game.printBoard();



}
}

public class TicTacToe
{

private int turn;
private String[][] board = new String[3][3];

public TicTacToe()
{
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
board[i][j] = "-";
}
}
}

//this method returns the current turn
public int getTurn()
{
return turn;
}

/*This method prints out the board array on to the console
*/
public void printBoard()
{

}

//This method returns true if space row, col is a valid space
public boolean pickLocation(int row, int col)
{
return true;
}

//This method places an X or O at location row,col based on the int turn
public void takeTurn(int row, int col)
{

}

//This method returns a boolean that returns true if a row has three X or O's in a row
public boolean checkRow()
{
return true;
}

//This method returns a boolean that returns true if a col has three X or O's
public boolean checkCol()
{
return true;
}

//This method returns a boolean that returns true if either diagonal has three X or O's
public boolean checkDiag()
{
return true;
}

//This method returns a boolean that checks if someone has won the game
public boolean checkWin()
{
return true;
}

}

Answers

Answer 1
ndjdjdbzkdkekkdjdjdkodododofiifidididiidieiekeieidid

Related Questions

You use a Windows system that is a member of a domain. The computer is used by several different users belonging to different groups. You have a custom application on the computer, and you want to configure the firewall as follows: Allow a specific port used by the application. Open the port only for members of the Sales group. Using Windows Firewall with Advanced Security, what should you do to configure the firewall with the least effort possible

Answers

Answer:

Explanation:

Windows Firewall with Advanced Security (WFAS) is a management tool in windows which allows for precise confiuration and control of the Windows Firewall System. It allows for certain rules to be created and modified which dictate to the firewall how it must run.

The easiest way to configure the WFAS to achieve the goal stated in the question is to open the app and use the New Rule function.

To do this, one must:

Calling up the Windows Firewall with Advanced Security (WFAS) Click on the inbound rules on the top left corner of the interfaceRight clickon the rule and modify accordingly

Cheers

help Which of the following triangles can be proven similar through AA?
Question 1 options:

A)

image

B)

image

Answers

A as in Ate my food ya know
Other Questions
PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!!PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! For each of the following examples, identify whether a positive or negative externality is present and whether there will be too little or too much of the activity relative to the socially optimal outcome. A. Jerome has a beautifully landscaped front lawn with lots of colorful flowers. Landscaped lawns produce a externality. landscaped lawns exist relative to the socially efficient quantity. B. Dave takes advantage of the low price of gas to purchase a sports utility vehicle. Sports utility vehicles generate a externality. sports utility vehicles are produced relative to the socially efficient quantity. C. Susan decides to walk to work instead of driving. Walking to work creates a externality. walks to work exist relative to the socially efficient quantity. D. Anita decides to smoke a cigarette while she is waiting at a busy bus stop. Cigarettes create a externality. cigarettes are produced relative to the socially efficient quantity. T=21and u =4 what is \sqrt(t+U) Which person below is likely to have better health?A. Jenna, who is optimistic about lifeB. Albert, who thinks that events in his life are not in his controlC. Peter, who is depressedD. Claire, who blames everyone else for her circumstancesSUBMIT Joe needs to get to his house,which is 106 miles away in 2 hours.How fast does he need to drive Which statement best completes the table?Structure of the Federal GovernmentThere are three branches of government.Each branch of government can check the power of the other two.Power is separated between three branches of government.A. The president is the head of all branches of government.B. Only the legislative branch is created by the U.S. Constitution.C. All branches of government create new laws.O. D. All branches of government have equal power. Melanie took two identical thermometers, one with its bulb painted black and the other with its bulb painted white. She kept a lighted lamp at equal distance from the two thermometers.Which thermometer will show a higher temperature after an hour? Thermometer with black bulb, because black reflects less heat than white Thermometer with black bulb, because black absorbs less heat than white Thermometer with white bulb, because black reflects more heat than white Thermometer with white bulb, because black absorbs more heat than white Andrew Young was part of the Civil Rights Movement because he was personal friends with(name)A. Ralph AbernathyB. MLKC.Maynard JacksonS. John Lewis I need this pls help me Which of the following might an author use to describe a character? Select all that apply. how others describe the character a.symbol b.actions c.setting d.dialogueNO LINKS PLS!!! Kailynn observed a SpaceX rocket on the launch pad in Cape Canaveral, Florida. The rocket is 230 feet tall, and Kailynn measures the angle of elevation between the base and the top of the rocket to be 5 degrees. How far is she from the base of the rocket?A-2629feetB-2639feetC-20feetD-231feetAnd explain An archer hits a target 50% of the time. Design and use a simulation to find the experimental probability that the archer hits the target exactly four of the next five times.MARK AS BRAINLEST FOR THE CORRECT ANSWER I1112211 / 22=>Which of the following hydrogen ion concentrations represents a solution with acidicproperties?A?1 x 10-8 M.?1 x 10-2 MC1 x 10-11 MD1x 10-13 MActivity IndexA Choose the correct answer.Between the years 1970 and 1976, what percentage change in the rate of exchange occurred in the German mark relative to the United States dollar (to the nearest percent)? % what is a scienctific theory A number of days, d, of sunshine is not 28. A manufacturing company applies factory overhead based on direct labor hours. At the beginning of the year, it estimated that factory overhead costs would be $341,900 and direct labor hours would be 48,900. Actual manufacturing overhead costs incurred were $307,800, and actual direct labor hours were 52,800. What is the predetermined overhead rate per direct labor hour A manufacturer has cube shaped cardboard boxes with an exact volume of 12000 cubic inches. What is the volum of the largest sphere that can be packed inside the cube shaped box? Give you answer rounded to the nearest whole cubic inch PLEASE NO LINKS OR FILES ALL IM ASKING IS FOR AN HONEST ANSWER PLASE AND THANK YOU WILL GET BRAILEAST IF CORRCT :)) Where is industry most concentrated? A. North America, East Asia, and EuropeB. North America, South America, and Central AmericaC. North America, South Asia, EuropeD. Europe, South America, and East, Asia