Вы находитесь на странице: 1из 2


Advanced Analysis & Object Oriented Design

Tutorial 4: Statechart Diagrams

1. Company A has a bug tracking system. This system has a UserAccount class which
represents a user in the system. Once the System Administrator creates a user, a
UserAccount object will be created with a pending state. The UserAccount object will be
active only when the System Manager approves the user. If the System Manager rejects
the user, the UserAccount will be in inactive state. The System Manager can call Activate
User and Deactivate User to move the UserAccount object to active or inactive state. The
system administrator will periodically call Delete User function to delete the UserAccount
objects, which are in the inactive state.

Draw a statechart diagram for the UserAccount object.

2. Draw a state chart diagram to show the different states of a Garage Door Opener described
below. The door is opened and closed by running a motor in front direction and backward
direction. There is a single button, which the user can use to control the Door.

3. The game of chess, since player White turn always goes first, the initial transition from the
start state points to the “whiteTurn” state. From then on, the game alternates between
whiteTurn and blackTurn states, until the game ends. There can be three possible
outcomes of the game, represented by the three end states; black can win, white can win,
or there can be a draw. The draw end state can be reached from whiteTurn state and
blackTurn state.

Show the conditions that should be present to determine when the system should transition
to each of the end states (‘blackWin’, ‘whiteWin’, and ‘Draw’) or to the regular states
‘whiteTurn’ and ‘blackTurn’.

5. Draw a state-chart diagram on the behavior of a telephone which is described as follows:

Initially, the telephone is in an “Idle” state. If the handset is taken off the hook it goes to
“Active” state. In “Active” state, the phone might be in any of the following sub states
starting with the “DialTone”

• When the user lifts the receiver, "dial" tone will be played.
• While the dial tone is being played the user may dial a telephone number.
• Telephone numbers consist of digits which have to be dialled one by one.
• If the user doesn’t dial any number after lifting the receiver for 15 seconds or if he takes
more than 15 seconds in dialing two digits, the phone will “Timeout” and play a message
asking to redial.
• When a complete number is dialed, the phone will move to “Connecting” state with the
receiver associated with it provided that the number is correct.
• If the number dialled is not correct, then the user will be informed that the number
dialled is wrong.
• While trying to connect, the receiver at the other end of the line may or may not be busy.
If it is busy the phone will start playing a "busy" tone.
• If the receiver at the other end of the line is not busy the phone will start playing a
"Ringing" tone.
• When the handset of the receiver at the other end of the line is taken off the hook the two
parties may start to talk to each other.
• If at any stage while the telephone is not idle the handset is placed back on the hook the
phone will get into the idle state again regardless of the exact state it was when the
handset was placed on the hook.