Master Class with changable Values!

The Idea is to have a master class, which saves different values. Many different classes are needing the values.

The problem is, I need to change the values. I need a solution that is really global, because…


Class1
MasterClass x = new MasterClass();
x.setValue(9);


Class2
x.getValue(); <---Doesn't work, even with new Master Class, because I create a new object.


And a don't want to add in every Constructor (MasterClass x). Any advise?

Are you familiar with Singletons?  It sounds like that may be the solution you're looking for.  Any web-search will turn up what you need, but it's basically a static object, of which there can only ever be one instance, and it will have a bunch of static methods you can call to get/set the values you want.

Ahh, ok I know what you mean!

That seems to be a good idea

Thanks

as an example, look for the 'Values' class in the following wiki entry:

http://www.jmonkeyengine.com/wiki/doku.php?id=fenggui_jme_appl_using_standardgame