I'm searching a way to creating different instances of different classes without writing a hacky code like:
PersonInstance pinstance = new PersonInstance();
FamilyInstance finstance = new FamilyInstance();
But with doing this it can go too far numbers of instances (like 70). Any ideas on how to make a good code without writing 70 lines that having the same sort of codes? If you didn't understand:
Initializing 70 different instances (different classes, everything different) with the classic method
PersonInstance instance = new PersonInstance();
for 70 times (different class, different instance identifier) is a bit hacky. I would like to know how to initialize them without using that way. Clearly all the classes have something common thing that they all extends on the same class. I want to know if it's possible or not?
If I understand this correct, you have to create a superclass for all your different classes. Example:
Then, you have to create an array or a list for example: