I am trying to make a TicTacToe game as part of a java lesson I am following along with. I completed the lesson, but there is a single line that processing claims is a syntax error that is stopping it from compiling. I cannot see any syntax errors here and have not noticed any others anywhere. I am new to processing and am inquiring if this is a common mistake made and what the real problem may be, or if I am just blind.
Edit: Full code as requested, apologies if it is hard to read
TicTacToeBoard board;
Stack boardHistory;
setup() {
size(400, 600);
TicTacToeBoard board = new TicTacToeBoard();
boardHistory = new Stack();
boardHistory.push(newBoard);
}
draw() {
background(255, 0, 255);
board.drawBoard();
stroke(255);
textAlign(CENTER, CENTER);
text("Current Player: " + board.getCurrentPlayer() + "\nWinner: " + board.getWinner(), width / 2, width + (height - width) / 2);
}
//Method for what happens when the mouse is clicked
void mouseClicked() {
int ind = board.inSpace(mouseX, mouseY);
if (ind[0] != -1 && ind[1] != -1) {
symbol = board.getCurrentPlayer();
board.getSpace(ind[0], ind[1]);
board.getCurrentPlayer();
board.setSymbol();
board.flipPlayer();
}
boardHistory.push(newBoard);
}
//Method for what happens when a key is pressed
keyPressed() {
if (keyCode = 37 && TicTacToeBoard.empty() = flase) {
boardHistory.pop(newBoard);
board = newBoard;
}
}
/CLASS TICTACTOESPACE/
class TicTacToeSpace {
//Variable declaration
int x, y, w, h;
String symbol;
//TicTacToeSpace constructor
TicTacToeSpace(int xIn, int yIn, int wIn, int hIn) {
x = xIn;
y = yIn;
w = wIn;
h = hIn;
symbol = " ";
}
//Method that checks if the spot is within the space
boolean inSpace(int xIn, int yIn) {
if (xIn > x && xIn < x + w && yIn > y && yIn < y + h) {
return true;
} else {
return false;
}
}
//Method that sets symbol
void setSymbol(String symIn) {
symbol = symIn;
}
//Method that draws a spaces symbol
void drawSpace() {
text(symbol, x+(w/2), y+(h/2));
}
//Makes a hard copy of the TicTacToeSpace
TicTacToeSpace copySpace() {
TicTacToeSpace newSpace = new TicTacToeSpace(this.x, this.y, this.w, this.h);
newSpace.setSymbol(this.symbol);
return newSpace;
}
}
/CLASS TICTACTOEBOARD/
class TicTacToeBoard {
//Variable declaration
int dim = 3;
TicTacToeSpace spaces = new TicTacToeSpace[dim][dim];
String currentPlayer;
String winner;
//TicTacToeBoard object constructor
TicTacToeBoard() {
currentPlayer = “x”;
winner = “???”;
}
//Nested for loop to number the spaces of the board
for (int row = 0; row < dim; row++) {
for (int col = 0; col < dim; col++) {
spaces[row][col] = new TicTacToeSpace(row * (width / dim), col * (width / dim), width / dim, width / dim);
}
}
//Current player methods
void setCurrentPlayer(String currentPlayerIn) {
currentPlayer = currentPlayerIn;
}
String getCurrentPlayer() {
return currentPlayer;
}
//Winner methods
void setWinner(String winnerIn) {
winner = winnerIn;
}
Sting getWinner() {
return winner;
}
//Method that changes the player
void flipPlayer() {
if (currentPlayer.equals(“x”)) {
currentPlayer = “o”;
} else {
currentPlayer = “x”;
}
}
//Method that returns spaces
TicTacToeSpace getSpace(int rowIn, int colIn) {
return spaces[rowIn][colIn];
}
//Method that returns a 1D array
int inSpace(int xIn, int yIn) {
int retArr = new int[2];
retArr[0] = -1;
retArr[1] = -1;
for (int row = 0; row < dim; row++) {
for (int col = 0; col < dim; col++) {
if (spaces[row][col].inSpace(xIn, yIn)) {
retArr[0] = row;
retArr[1] = col;
}
}
}
return retArr;
}
//Method that draws the board
void drawBoard() {
stroke(255);
for (int i = 1; i < dim; i++) {
rect(i * width / dim, 0, 1, width);
rect(0, i * width / dim, width, 1);
}
for (int row = 0; row < dim; row++) {
for (int col = 0; col < dim; col++) {
spaces[row][col].drawSpace();
}
}
}
//TicTacToeBoard constructor
TicTacToeBoard(TicTacToeSapce spacesIn) {
for (int row = 0; row < dim; row++) {
for (int col = 0; col < dim; col++) {
spaces[row][col] = spacesIn[row][col].copySpace();
}
}
}
//Makes a hard copy of the TicTacToeBoard
TicTacToeBoard copyBoard() {
TicTacToeBoard newBoard = new TicTacToeBoard(this.spaces);
newBoard.setCurrentPlayer(this.CurrentPlayer);
newBoard.setWinner(this.winner);
return newBoard;
}
}