I'm writing an interactive fiction game with scratch in Java. I am currently storing all of my object object references in Hashp in singleton named Object Manager. The object manager has a function name that takes an integer ID and gives proper reference. The problem is that when I need to return the sub-squares of BaseObject with more functionality, it returns a base object
So, what I have done so far I added a getEntity function Which gives the basetexti (which is the subclass of the base object). However, when I need a function to return to that object which is a sub-orbit of the basinty which has been added, the required functionality, I will need to create another function I know that there is a better way, But I do not know what this is. I know very little about the design pattern, and I'm not sure who will use it here, I tried to pass the 'class' as a parameter, but I could not find it anywhere.
Public base object received (id) {Return (base object) refMap.get (id); } Public Bentity GateInty (Int ID) {Return (BassInty) Ref: Gate (ID); }
Thanks, Java Ninja!
If you have Java 5 runtime then use the normal return type:
public & lt; Unit BaseInteity & gt; Unit gate (int id) {returns (unit) refMap.get (id); }
Comments
Post a Comment