Page 78 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 78

Object Oriented Analysis and Design




                    Notes
                                          Figure 6.16: State Machine with three States: “Opened”, “Closed” or “Locked”



















                                   Source: http://www.ddegjust.ac.in/studymaterial/mca-5/mca-503.pdf
                                   The door can be in one of three states: “Opened”, “Closed” or “Locked”. It can respond to the
                                   events Open, Close, Lock and Unlock. Notice that not all events are valid in all states; for
                                   example, if a door is opened, you cannot lock it until you close it. Also notice that a state
                                   transition can have a guard condition attached: if the door is Opened, it can only respond to the
                                   Close event if the condition door Way->isEmpty is fulfilled.


                                          Example: Let us take another example of the state diagram for an Order object as shown
                                   in Figure 6.17. When the object enters the Checking state it performs the activity “check items.”
                                   After the activity is completed the object transitions to the next state based on the conditions [all
                                   items available] or [an item is not available]. If an item is not available the order is canceled. If
                                   all items are available then the order is dispatched. When the object transitions to the Dispatching
                                   state the activity “initiate delivery” is performed. After this activity is complete the object
                                   transitions again to the Delivered state.
                                                      Figure 6.17:  State  Diagram for an Order  Object




























                                   Source: http://www.ddegjust.ac.in/studymaterial/mca-5/mca-503.pdf





          72                                LOVELY PROFESSIONAL UNIVERSITY
   73   74   75   76   77   78   79   80   81   82   83