Question: What is the error? On line 9 4 it says I need a { after the } but I dont know where to
What is the error? On line it says I need a after the but I dont know where to put it
import java.util.Scanner;
public class TicTacToe
private char board;
private int turns;
public TicTacToe
board new char;
turns ;
for int i ; i ; i
for int j ; j ; j
boardij;
public boolean isValidint r int c
return r && r && c && c ;
public char playerAtint r int c
if isValidr c
return boardrc;
return ;
public void playMovechar player, int r int c
if isValidr c && board rc
boardrc player;
turns;
public boolean isFull
return turns ;
public boolean isWinnerchar player
for int i ; i ; i
if boardi player && boardi player && boardi player
return true;
if boardi player && boardi player && boardi player
return true;
if board player && board player && board player
return true;
if board player && board player && board player
return true;
return false;
public int getTurns
return turns;
public String toString
StringBuilder sb new StringBuilder;
for int i ; i ; i
sbappend;
for int j ; j ; j
sbappendboardijappend;
sbappend
;
return sbtoString;
public static void mainString args
Scanner keyboard new ScannerSystemin;
playGamekeyboard;
private static void playGameScanner keyboard
char p X;
TicTacToe ttt new TicTacToe;
int r c;
do
System.out.print p choose your location row column:;
try
r keyboard.nextInt;
c keyboard.nextInt;
if tttisValidr c
System.out.printlnNot a valid location! Try again.";
else if tttplayerAtr c
System.out.printlnLocation is already filled! Try again.";
else
break;
catch Exception e
System.out.printlnBad Integer Entered. Try Again.";
keyboard.nextLine;
while true;
tttplayMovep r c;
p p XO : X;
while tttisWinnerX && tttisWinnerO && tttisfull;
System.out.printlnttt;
String status;
if tttisWinnerX
status X is the winner!";
else if tttisWinnerO
status O is the winner!";
else
status "Tie!";
status After tttgetTurns turns.";
System.out.printlnstatus;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
