I have to write a somewhat simple game for a project, and I am trying to make one class for the actual game with all of the rules and gameplay code, and another class for the GUI.
The GUI is still going to need to access some of the methods of the Game class though, so I was trying to figure out a way that I could still call some of the methods, and I found something
online which I tried to implement.
Ok in the Game class, I construct a Game object called myGame and then do this
Which is supposed to create an instance of the GUI class. That part does work because when I set gameGui to visible, it appears properly.
In GUI class I have
This will compile, but if I try to run a method like getGame().getPoles() I will get a null pointer exception. Also, if I just try to print out
a
String containing getGame(), it will print null. I am unsure of whether the getGame() method is not working, or if the whole thing is not working
and the Game is not being set properly. Any help is appreciated.