Skip to main content
1 of 2
Zircon
  • 4.7k
  • 17
  • 34

A static variable belongs to the class, not the object, so of course all of your GameBoards are being affected!

Just because you're in a static method doesn't mean you can't manipulate instance variables. First, make everything in your GameBoard class non-static (unless you really do need some of the values shared across all instances). This includes your instance variables and your getter/setter methods.

If your program works exclusively from the main method, then keep your GameBoard[] object static. Then, when you make that method call:

gameboard[input].setState(2); 

This will change only the state of the GameBoard at index input.

Zircon
  • 4.7k
  • 17
  • 34