Thank you Maulin, Alton and Bert for taking an interest in my question.
Can you eliminate the recursive aspect from your example and restate the question?
Yes and No.
My second question was whether the has-a relationship is a transitive relationship?
class C { D d = new D(); }
class D { E e = new E(); }
C has-a E?
Thank you Alton for your point of view. I have also discovered that the UML Reference Manual says both generalization and aggregation are transitive. So that question is answered.
The question on the mock exam asks you to select all valid answers.
(a) C is a B
(b) A has a C
(c) B is a A
(d) A is a B
(e) B has a C
When I drew a UML diagram, I noticed the unusual aggregation from A to B. By way of contrast, in the Composite and Decorator
patterns, B extends A
and B aggregates A.
I could not imagine how to write code to instantiate a B without getting into trouble. Thank you Maulin for your comments.
My first question is: Look at this pathological has-a relationship. Does it confuse you as much as it confuses me?
[ July 17, 2003: Message edited by: Marlene Miller ]