1、Suggested answer for Exercise 2.1The class diagram is shown below. Note the following: 1. Fields in the Java classes that store references to other objects are shown in UML as associations between the classes, not as attributes. 2. The cost function in the Component class is abstract: this is shown
2、in UML by writing it in an italic font, as with the class itself.Suggested answer for Exercise 2.2(a) The diagram below uses the names of the variables in the code as object names. Although this probably clarifies the current example, it runs the risk of confusing the two distinct concepts of object
3、 name and variable name. This is potentially dangerous in an environment where objects are reassigned to different variables. This diagram illustrates the different numbers of part objects that can exist for a catalogue entry: zero, one or many. (b) Apart from the assembly object, all the objects in this diagram have already appeared in the answer to part (a). (c) A client object has been added in this diagram, shown as sending the initial cost message to the assembly.