I have a Quad class (for my sprites) and within this class are various variables for altering the state of said Quad. So I can simply make a sprite like so:
Quad hero = new Quad();
I have a Resource class where all of my sprites are held/created.
I have a Main class which is not a neighbouring class of Resource, therefore to keep from breaking the rule of Demeter, I have created various getters/setters in the Resource class (which is a neighbour of Main).
However, as I have so many variables that need to be accessed, is there a better way of creating a getter/setter for each variable?
I'd like to do something like being able write a getter which simply returns a Quad so I can then access it's variables within the Main class. So in Resource, I would have something like so:
public Quad getQuad(Quad quad){
return quad;
}
And then in my Main class I want to so something like this: ('res' is an object of my Resouce class)
res.getQuad(hero).variable;
I realise the above doesn't work - it's just an example of the kind of thing I would like to achieve.
Or maybe there is code I could put in the getter itself that would allow me to access any of it's variables rather than a specific one.
This is just so I don't have to break Demeter by doing this which I have been assured on many occasions is not good practice:
res.hero.variable;
Would be grateful for any help.