Java Inheritance and Types
Hello,
I have some super/sub classes, listed as follows:
UnitMgr
SpecialUnitMgr (child of UnitMgr)
Unit
SpecialUnit (child of Unit)
I'm designing a lot inventory system where my SpecialUnitMgr applet will have many instances of Unit. Right now I have the system set up so that UnitMgr contains an instance var declared as "Unit aUnit;". UnitMgr as a parent class, takes care of common code between the many different UnitMgr child classes.
Right now I have SpecialUnitMgr setup to use the inherited parent/super variable aUnit, and I have extended the functionality of Unit with SpecialUnit (added more instance vars, etc). I wish to use extended features of SpecialUnit within my SpecialUnitMgr class, but I am unable to do so because of type conflicts (i.e. i cant access SpecialUnit vars or methods from the instance aUnit because it is declared as Unit in UnitMgr).
I want to keep a single instance of Unit or SpecialUnit going, but I'm not sure how to do so.
I am wondering how to get around this problem, do I use Reflection? Is my design bad? I am trying to maintain the super classes as a core package.
Jeff

