Hi.
A question about relationship between subclasses of two hierarchies.
If I have two hierarchies, where root classes are, for example: Car and Driver. Subclasses are CarType1,CarType2 and DriverType1,DriverType2.
I want to model a relation such as "drive" or "is driven by", but I want to say two things:
1) each Driver---drive---a Car;
2) DriverType1 have to drive CarType1, DriverType2 have to drive CarType2.
Well. I have put a relation between parents Driver and Car in order to satisfied 1).
The second constraint (2) have to be exspressed with a relation between DriverType1(or 2) and CarType1(or 2)??
Is it reasonable in an object oriented design??
In what way such a system will be used with polymorphism??
A question about relationship between subclasses of two hierarchies.
If I have two hierarchies, where root classes are, for example: Car and Driver. Subclasses are CarType1,CarType2 and DriverType1,DriverType2.
I want to model a relation such as "drive" or "is driven by", but I want to say two things:
1) each Driver---drive---a Car;
2) DriverType1 have to drive CarType1, DriverType2 have to drive CarType2.
Well. I have put a relation between parents Driver and Car in order to satisfied 1).
The second constraint (2) have to be exspressed with a relation between DriverType1(or 2) and CarType1(or 2)??
Is it reasonable in an object oriented design??
In what way such a system will be used with polymorphism??