Association can be correct, because aggregation or composition are special kind of associations.
Aggregation would be better (i.e. more precise), because it expresses a whole-part relationship. Here, Colleges
are a definitively parts of the whole University
, and Departments
are parts of a whole College
.
Composition is similar to aggregation, but with an exclusive ownership of the parts by the whole. So it's also a candidate here. However composition would mean that a College
would exist only as part of a specific University
; so when the University
gets removed, so does the College
. But this semantic would not correspond to the academic reality. The reality is that occasionally a department moves from one college to the other, or that universities in the same town get merged, but the underlying colleges still remain unchanged except for their logo. With composition, this would require to clone a College
into the new University
and destroy the original one (so after the operation, you'll have a new college), whereas with aggregation a simple reassignment would be sufficient. So aggregation is the way to go.
Now there are tools like BoUML, and lots of other tools (just google for UML class diagram generate java code
) that transform an UML diagram in Java. But if you're learning, and for this specific example, it's also easily done manually (see for example this tutorial).