Next, we will define the stopwatch Classifier and its structural features by using a Class diagram. We will start by creating a new package to store the stopwatch model.
To create a new package to store the stopwatch model
- Right-click Model in the containment browser and select New Element > Package. A new package will be created under the Model node. Name the created package "system".
- Create a new Class diagram in the system package by clicking the Class Diagram button on the Diagrams toolbar. The Create Diagram dialog will open.
- Name the Class diagram "System" and select the system package as the diagram owner.
Click OK.
Note
You can also use the context menu of the system package to create a new Class diagram by right-clicking the system package and select New Diagram > Class Diagram.
- Use the diagram toolbar of Class Diagram to create a new Class Element and name the created Class "StopWatch".
We will then add a Time Attribute to the StopWatch Class. Since this Attribute represents the elapsed time in seconds, it will be typed by an Integer data type.
To add a Time Attribute to the StopWatch Class
- Click the manipulated button (the small orange button) in the StopWatch Class. A new Attribute will be created in the StopWatch Class.
- Name the Attribute "time" and type it with an Integer by directly typing it into the Attribute compartment of the StopWatch Class.