Lab 1 Rational Rose Class Diagrams

Rational Rose is a tool developed by rational to allow users to easily create class diagrams, interaction diagrams, use case diagrams, state machines and other diagrams.

A class diagram is a model that represents the structure and form of a piece of software. The main thing that a class diagram does is allows you to define all the classes that will be implemented in the project. It also allows you to define the variables/attributes and methods/operations that a class will have. On the diagram each class is represented by a box that is labeled with the name of the class, the variables, and the methods of the class. In rational rose you may also show associations between your classes. The three primary types of associations that you can show are normal associations, unidirectional associations, and aggregation.

Opening Rational Rose

To open rational rose, go to start -> programs -> Rational Rose -> Rational Rose Enterprise edition.

This will launch the application. When the program loads, it will automatically display the Create New Model Dialog. In this dialog you are given the option of creating a model for many languages including java and c++. You want to create a model for C++. To do this click on the icon labeled VC6 MFC 6.0 and then click OK. This will open a workspace on which you can create your class diagram.

When the workspace is created there will be a folder in the workspace labeled MFC 6.0. You will want to remove this from your model. To do this click on the folder and go to the Edit menu and select Delete From Model or you can use Ctrl+D. You do not want to just push the delete key. If you just push the delete key the folder will not be visible, but will still be a part of the model.

Add A Class

To add a class to your model, go to tools menu -> create menu -> class or click on the fourth button down on the tool bar. Then click where you want the class to appear in the workspace. This will create the class and make it visible. You can then name the class.

Modifying A Class

To Modify a class you use the Class Specification Dialog. You can open this dialog by double clicking on the class or right clicking on the class and selecting Open Specification…

Variables in Rational Rose are called Attributes. To add an attribute to a class, open the specification dialog and go to the attributes tab. In this tab, there will be a white box. To add an attribute right click in the white box and select insert. This will add an attribute and allow you to name the attribute.

You may modify an attribute by using the Attribute Specification Dialog box. You can open this dialog by double clicking on the attribute or right clicking on the attribute and selecting Specification… In this box you can set the type of the attribute, the initial value of the attribute, and say whether the attribute is public, private, or protected.

Methods in Rational Rose are called operations. To add an operation to a class, open the specification dialog and go to the Operations tab. The insertion process is the same for the operations. The only difference is where you are adding them.

You can modify an operation in the same way that you modified an attribute. Open the specification dialog for the method. When the dialog is open you can change the name, set the return type, and say whether the method is public, private, or protected.

You can also add parameters to a method in the methods specification box. To do this go to the Detail tab. To add a parameter right click on the white box and select insert. You can set the type for the parameter by opening the specification for the parameter.

Showing Associations

You can show associations between classes in your model. To do this you go to tools menu -> create -> “association or unidirectional association or aggregation”. When you have selected the type of association you then click on one of the classes and drag you mouse to the other class. When you release it will draw the requested type of line. A plain association is represented by a plain line. A unidirectional association is represented by an arrow. An aggregation is represented by a diamond on one side of the association.

You can set the multiplicity of an association as well. To do this, right click on the association line close to one of the classes. Then select the desired multiplicity. Repeat this process on the other side of the association.

Assignment

Create a class diagram that has four classes

Each class must have 3 attributes and three operations

For both methods and operations you must have 1 private, 1 protected, and 1 public entity

Each method must have two parameters and a return type. You must define the type for

the parameters

Each attribute must have a type

Create one normal association, one unidirectional association, and one aggregate association. You must show multiplicity on all of the relationships.