< Previous | Next >

Creating the On Hook state

When it is in the On Hook state, the state machine is quite simply waiting for an event to happen. An offHook operation will signal that the phone is about to be used, and an unplug operation means that it is going to be disconnected.

In this step, you will do the following:
  1. Click the InitialState1, and rename it to Start.
  2. Similarly, rename FinalState1 to End, and State1 to On Hook.
  3. Add and configure an entry for this state
    1. Click On Hook, and select the Add an Entry icon from the action menu that pops up.
    2. Click this new entry, and rename it to ReceiverOnHook.
    3. In the Properties view, click the Details tab, and click the Java radio button.
    4. Paste the following code into the Java editor:
      System.out.println("Pick up receiver to start dialing.");
  4. Create an action on the first transition.
    1. Click the transition between the Start and On Hook states.
    2. From the action menu, click the Add an Action icon, and name it InitializeTelephoneNumber.
    3. Add the following code to the Java editor:
      telephoneNumber = init_Input_id;
  5. Create an action on the second transition.
    1. Drag and drop the unplug operation from the Interfaces area to the transition between the On Hook and End states.
    2. Create an action named end with the following code:
      java.lang.String __result__1 = "Unplugged, ending";
      {// print to log
      	System.out.println(__result__1);
      }
Your states and transitions should look like the ones in this image:
The Start, On Hook and End states as they should look as you begin to create this state machine.

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.
< Previous | Next >