Professional Documents
Culture Documents
Compiled By :Umm-e-Laila
Lecture 25
Course Books
Text Book:
The Complete Reference Java2 by Patrick Naughton
&Herbert Schildt
Reference Books:
Beginning Java 2 by Ivor Horton
2
Course Instructors
Umm-e-Laila ulaila2002@gmail.com
Assistant Professor, CED
Room Number: BS-04
Tel: 111-994-994, Ext. 536
Section B, D (Computer, Batch 2014)
http://sites.google.com/site/ulaila206
5
Marks Distribution
6
State Diagrams
Objects can be either:
Passive (current status of attributes)
Active (status as it undergoes a continuous
transformation)
State diagrams concentrate on the active states
of a single event-driven object
An event occurs to force an object to make a
transition from one active state to another
Events must be discrete rather than continuous
Begin with externally observable states. Later,
you can refine these states into behaviours that
are not evident from outside the system
State diagrams owe much to the theory of finite
automota
Basic UML State Diagram
State
Ready
Event
Done Guard
Transition Action
stop
Final State
State Components
Transitions:
Three parts, all optional Event [Guard] / Action
Events (or triggers)
Guard is a logical condition returning “true” or
“false”. Transition occurs only if the condition is
true. Guards exiting a state must be mutually
exclusive
Action represents a processes which occurs
quickly and is not interruptible
Label
States:
Two parts, label and activity do/activit
y
Activity represents a process which is longer than
a transition action and can be interupted
Case Study: Voronoi Diagram State
Initiating Renderin
[no. particles = g
Generate n] Project Projection
Particles Particles complete
Centering
[no. iterations <= Find
m]
Centroids
Centroids
Repositioning calculated
[no. iterations >
m] Alter
Positions
Exercise: Control Panel State
Create a state diagram from the following
narrative:
The homeowner uses the keypad to key in a four-
digit password. The password is compared with the
valid password stored in the system. If the password
is incorrect, the control panel will beep once and
reset itself for additional input. If the password is
correct, the control panel awaits further action.
[password = incorrect] / beep & reset
Selling Happy
Unhappy
Summary: Object-Behavioural Models
State diagrams are good at describing the
behaviour of a single object across several use-
cases
Interaction diagrams useful for describing the
behaviour of several objects in a single use
case
Two flavours of interaction diagrams:
Sequence Diagrams: Objects in the
horizontal, time in the vertical
Collaboration Diagrams: Objects connected
by numbered events
Roughly equivalent
Use each object-behaviour diagram in the
situation for which it is most appropriate