So lets say I have several classes.
public static void main(String arg[]){
MapBuilder mainMap = new MapBuilder();
Player mainPlayer = new Player(mainMap);
Screen mainScreen = new Screen(mainMap, mainPlayer);
}
My question is about how to enable them to work with and reference each other. Basically, I want the player object to be able to use the maps methods and the screen object to be able to use the player and the map methods. As you can see, right now I have it setup so that the references the map get sent to the player and the screen constructors and the player object gets sent to the screen as well. So, first question, is this an appropriate way to be doing this? It works, but I don’t know if its considered good programming.
But even if that is a good way to do that, I have a problem. I also want the map object to be able to reference the player and the screen. However, when the map is initialized, the player and the screen haven’t been initialized, so I can’t pass them to the constructor.
Hopefully that’s enough for you to understand what I’m getting at. So am I on the right track? Or am I going about this the completely wrong way?