|
RHS |
UML02
In UML01 you had to implement the association between Owner and Car. There is at least three ways of doing that in Java:
Which to choose depends on the context. Looking in use cases, sequence diagrams and other documentation can be of help when choosing one.
The first solution makes it necessary to have a reference to an owner to get information about his car. The second makes it necessary to have a reference to a car to get information about its owner. The third makes it hard to construct two connected objects.
So all solutions have their advantages and disadvantages.
We choose the first solution!
To solve this exercise you have to have a solution for UML01 as we'll extend it.
You can download a solution for UML01 here: Exercises
Looking at the class-diagram we can see that we have to make the classes Engine, CDPlayer and Airbag - all parts of a Car.
![]() |
To help you a little you can download the basic classes here : Engine.java, CDPlayer.java, Airbag.java
Now you have to implement the three compositions between Car and these three classes - please note that the multiplicity is different for all compositions!
Also make the necessary changes in TestUML so you can test these new classes.