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".
![Magic Model Analyst 2021x Refresh1 > Creating the stopwatch structure > worddavcbf13a2eed10e9f0ad36880954bb8398.png (Creating a Package Named System) Creating a Package Named System](/download/attachments/106655582/worddavcbf13a2eed10e9f0ad36880954bb8398.png?version=1&modificationDate=1496884839188&api=v2)
- 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.
![Magic Model Analyst 2021x Refresh1 > Creating the stopwatch structure > new-diagram-menu.png (The Create Diagram Dialog) The Create Diagram Dialog](/download/attachments/106655582/new-diagram-menu.png?version=1&modificationDate=1496884839291&api=v2)
- Name the Class diagram "System" and select the system package as the diagram owner.
Click OK.
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".
![Magic Model Analyst 2021x Refresh1 > Creating the stopwatch structure > worddav9d2a257d15dee27f02355f217932ae9e.png (Creating the StopWatch Class) Creating the StopWatch Class](/download/attachments/106655582/worddav9d2a257d15dee27f02355f217932ae9e.png?version=1&modificationDate=1496884839608&api=v2)
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.
![Magic Model Analyst 2021x Refresh1 > Creating the stopwatch structure > worddav96fbc3722aee48918b184b38ee181f39.png (Adding a Time Attribute to the StopWatch Class) Adding a Time Attribute to the StopWatch Class](/download/attachments/106655582/worddav96fbc3722aee48918b184b38ee181f39.png?version=1&modificationDate=1496884839722&api=v2)