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


  1. 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".

    Creating a Package Named System

  2. 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. 

    The Create Diagram Dialog

  3. Name the Class diagram "System" and select the system package as the diagram owner.
  4. 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

  5. Use the diagram toolbar of Class Diagram to create a new Class Element and name the created Class "StopWatch"

    Creating the StopWatch Class



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


  1. Click the manipulated button (the small orange button) in the StopWatch Class. A new Attribute will be created in the StopWatch Class.
  2. Name the Attribute "time" and type it with an Integer by directly typing it into the Attribute compartment of the StopWatch Class.

    Adding a Time Attribute to the StopWatch Class