In this lesson, you create an object model diagram. Object
model diagrams (OMDs) specify the structure and static relationships
of the classes in the system. IBM® Rational® Rhapsody® object
model diagrams are both class diagrams and object diagrams, as specified
in the UML. They show the classes, objects, interfaces, and attributes
in the system and the static relationships that exist between them.
To create an object model diagram:
- In the Rational Rhapsody model
browser, expand the VehicleSensor project.
- Right-click the Design package and select .
- In the New Diagram dialog box, rename the diagram. The
diagram is added in the browser.
- To draw the first class, in the drawing toolbar, select
the class
icon and click in the drawing area.
- Place the cursor in the top panel of the class and replace
the default name with Button.
- Draw two more classes and name them Sensor and Display.
- Right-click the Sensor class and select Add
New > Attribute.
- Rename the attribute Pulse.
- Double-click Pulse to display the Attribute
dialog box.
- Select the General tab and enter the values as shown:
- Right-click the Sensor class and
select .
- Double-click the new operation to display the Operation
dialog box.
- Select the General tab and rename the operation resetSensor.
- Select the Implementation tab and type pulse=0;,
then click OK.
- Select the display class and add an operation named show(count:int).
- Add the following code in the Implementation tab: std::cout <<
"the pulse count is " << count << std::endl;.
- Add an association line from Button to Sensor.
- Add another association line from Sensor to Display. Your
diagram must resemble this figure: