When the StopWatch State Machine enters the ready State, the elapsed time defined by the attribute time: Integer should be reset to zero. In addition, the elapsed time should increment by 1 every second while the StopWatch is in the running state. You can define this functionality using Alf in two Operations on the StopWatch Class: resetTime and increaseTime. These operations will later be called from the entry Behaviors of the appropriate states in the StopWatch State Machine.
To create the resetTime Operation
Enter the Alf code shown in the figure below.
To create the increaseTime Operation
Click on the increaseTime operation and, in the Alf editor window, press Create.
Enter the Alf code shown in the figure below.