I have a dwelling
class which is a generalization of house
and building
. Those classes have their own properties, and the class floor
is a composite of building
.
I would like to associate a person
class. If a person lives in a building, I want to be able to retrieve the matching floor. The best solution I found is to import all properties in the parent class and make them nullable.
Q: Is there a more elegant way to deal with such scenario ?
EDIT: I forgot to say (and to draw) that dwelling
is an abstract class, as a :dwelling
is either a :building
or a :house
. As I cannot predict in which a :person
will be, the relationship should only involve the dwelling
class. But how instantiate once I know ?