Release date: Tuesday, 14.04.15 - Due date: Sunday, 19.04.15, 23:59
Give us four examples of a part-whole relationship, two examples of an aggregation and two examples of a composition relationship. Argue for each of the four cases why it is an aggregation or an composition respectively. (Such an argument would consist of the generic criterion for choosing the respective type of association and one or two sentences arguing why the criterion applies here.)
[Optional, 0 points]: Can you find an example where it depends on the context whether it is an aggregation or composition.
|9 = 5 + 4 points|
Studying class diagrams can be as exciting as hunting down gangsters. This task is the proof. Below you find a class diagram explaining that gangsters are persons and that certain associations are possible between gangsters and persons:
Study the class diagram carefully and understand which associations can connect objects of which class. With this knowledge you can easily solve the following two subtasks.
a) Study the object diagram carefully and tell us:
Make sure that you don't accuse a person of being a gangster, if you can not be sure. Accusing a person that might still be person will cost you a point per wrong accusation!
b) For the four persons above we know already whether they are gangsters or just persons. Given the class diagram above, which associations are possible between the following pairs (in the indicated direction)?:
Name all possible associations.
Enjoy the beautiful drawing we created for you with JHotDraw 5.11)
The goal of this task is to give you a first feeling about how classes, objects and the implementation relate to each other.
If you enjoyed the drawing long enough, check out the following projects/files:
oosc-is-ok.serfrom the same folder.
We are only interested in the classes and interfaces that are already shown in the class diagram in your file. Explore the source code2) in the package
CH.ifa.draw.figures and add the following to the class diagram:
extends) and implementation (
implements) relationship between these classes and interfaces.
Ignore the static fields, ignore the transient fields, ignore the fields related to serialization (field names contain “serial”). You don't need to add any attribute, just add associations.
Now complete the “Object Diagram” so that it shows all the objects and their attribute values in the drawing that we created. You already find a few “instance specifications” (=“objects”) in the file. You are free to guess the coordinates and the color (names), but be consistent. Make sure that you represent all the objects in the drawing. The class diagram should be helpful for that.
As solution we expect your updated
A02T06_JHotDrawFigures.astah file in your
Assignment02-GXY folder. Keep the source code of JHotDraw just in your workspace, we don't need it in the repository.
For the curious: You can load the drawing
oosc-is-ok.ser into the application. You find
JavaDrawApp.java in the package
CH.ifa.draw.samples.javadraw. Right click on the file and select “Run As …” > “Java Application”.3)
Give us for each of the four class diagrams above:
(even more optional) We claim that the two last diagrams are equivalent.
F3(on a class, field or method name),
F4(on a class name),
Ctrl-O(anywhere in class),
Ctrl-T(on a class name),
Ctrl-Shift-G(on a class, field or method name),
DrawApplication.java, start with “Debug As …” , load the drawing file, switch to the Debug perspective and explore
this.fDrawing. It's a bit more complicated than you might expect, but with some endurance you find the information. And there other tricks to get the data…