the student and teacher class inherited from person class, because inheritance is not flexible the object will either be one of the two. to solve this i added an abstract cl