posted 16 years ago
Well, UML is pretty near the implementation but here is my take on p140, in a very simple eample (the UML doesnt specify any access modifers or return types so I made all the methods default and the instance variable.
The main pont I think here is just to show the UML representation of Composition. The code doesnt really show more than the basic Association and Navigation (the getQuestion() Method). To represent composition in the code the constructor for the Question class would need a reference to an exam object or something similar to show that the lifecycle of the question(s) is dependent on an exam object.
[ October 26, 2008: Message edited by: Stephen Davies ]
be a well encapsulated person, don't expose your privates, unless you public void getWife()!