Vous êtes sur la page 1sur 5

W228/304 ______________

WINTER EXAMINATIONS 2008-09


______________

DT2283 Soft Eng III Solutions

Page 1 of 5

W228/304

2. (a) Explain the following terms used in state transition diagramming. (i) Transition (ii) Event (iii) Guard Condition (iv) Entry Action (v) Exit Action (vi) Do Activity [6x2 marks] Transition: movement from one state to another triggered by an event Event: A situation that arises that initiates a change of status. Guard Condition: A condition that must be true before the event will fire the transition. Entry Action. A method of the object that executes each time the object enters the state regardless of the event or transition. Exit Action: A method that is executed an object leaves a state regardless of the event or transition. Do Activity: A method that executes continuously while an object is in a state. (b) Draw state transition diagram for the consultant referred to in question 1 using the description below. Use sub-states where applicable. A consultant will receive induction training immediately on been hired by the consulting company. After he/she completes their induction training successfully they will be deemed qualified and will wait to be assigned to a client. When a suitable client assignment is secured they will go on site at the clients office. Occasionally he/she may return in-house for specific training but will remain assigned to the client. The consultant may take holiday leave during any stage of their assignment or while unassigned. They cannot take holiday leave during induction training. When they return from leave they will resume at the point they left off. Marking Scheme: Set of States. Events and their transitions as illustrated in diagram Representation of the logic of the transitions and states Correct notation and any relevant sub-state modelling: 2 marks 3 marks 3 marks 2 marks [10 marks]

DT2283 Soft Eng III Solutions

Page 2 of 5

W228/304 (c) The narrative above states when a consultant takes leave he/she resumes to the same state when they left. Show on your statechart how the History State is used to represent this. Explain using program code, pseudocode or otherwise, how the return from leave event can be implemented. [11 1/3 marks] The history state needs to be set whenever a transition leaves the composite state. Store the leaving substate in a variable. This would be coded in the leaveGranted() method private int historyState ; public void leaveGranted() { switch (state) { case InHouse: case OnSite: UnAssigned historyState = state; state = OnLeave ; break ; case InductionTraining: break ; } public void ReturnFromLeave() { switch (state) { case OnLeave: state = historyState ; break ; // other cases }} This is the type of code discussed in lecture for similar problems. I would accept an explanation of the principles involved if the code proved too technical.

DT2283 Soft Eng III Solutions

Page 3 of 5

W228/304

hired

Induction Training completed training Qualified

hired

Unassigned assigned Assigned to Cust H

Leave Granted

In house training completed in for training

return from leave

On Leave

leave granted On site

Solution to Q 2 (a)

DT2283 Soft Eng III Solutions

Page 4 of 5

W228/304

DT2283 Soft Eng III Solutions

Page 5 of 5

Vous aimerez peut-être aussi