I'm trying to make a Tic Tac Toe game for my Java class. I am not able to use JButtons only JPanels. I'm stuck on the part where my program determines if there are 3 x's or o's in a row.
public void winner()
{
if(3 = tictactoe[0].turn + tictactoe[1].turn + tictactoe[2].turn)
{
System.out.println("X has won");
}
}
I had established turn as being a 1(x) or a 2(o). If 3 panels in a row [0] + [1] + [2] = 3 then it would mean that "x" had won. I need to add more to it to check all panels but I am getting errors just testing it. tictactoe[] are the panels 0-8. Turn is in the class "MousePart" which contains the MouseEvent. Three of the errors are that it cannot find the variable turn. I'm not sure how to establish it so it knows to go to MousePart. The Fourth error is unexpected type - probably being the 3 = tictactoe[]. I'm not sure what to do.