0% found this document useful (0 votes)
3 views4 pages

Tutorial 2

this is des

Uploaded by

d20241110891
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Tutorial 2

this is des

Uploaded by

d20241110891
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DES3023 SOFTWARE REQUIREMENTS AND SPECIFICATIONS

TUTORIAL 2: STATE CHART DIAGRAM

Case Study 1: Library Book Borrowing System


A library system keeps track of the state of a book.
• A book is available in the library.
• A student can borrow the book.
• After borrowing, the book becomes borrowed.

• The student later returns the book.


• If the book is returned late, the student must pay a fine.
• After the book is returned, it becomes available again.

1. What is the object being modelled in this system?


Book

2. List the states of the book.

1. Available

2. Borrow

3. Return

4. Late return with fine

3. Which state is the starting state of the book ?

Available
4. Draw a State Chart Diagram.

5. Why is it important that a book cannot be borrowed if it is already in the Borrowed state?

It is important that a book cannot be borrowed if it in the borrowed state because to prevent
more than one student from borrowing the same book and to ensure correct book availability in
the system.
Case Study 2: Coffee Vending Machine
A coffee vending machine has a simple behaviour:

• The machine starts in Idle state.

• When a customer inserts money, the machine moves to Waiting for Selection.

• The customer selects a drink: Coffee or Tea.

• The machine moves to Preparing Drink.

• After preparation, the machine moves to Dispense Drink.

• Once the drink is dispensed, the machine returns to Idle.

• If the customer cancels before selecting a drink, the machine returns the

money and goes back to Idle.

1. What is the object being modelled in this scenario?

Machine

2. List the states of the coffee vending machine.

1. Machine in idle state.

2. Machine waiting for selection.

3. Machine ready to prepare a drink.

4. Machine dispense a drink.

3. Identify the initial state and final state.

Initial state: Machine in idle state.

Final state: Machine in idle state.

4. Identify the events that cause transitions between the following states:

FROM STATE TO STATE EVENT


Idle Waiting for Selection Customer inserts money.
Waiting for Selection Preparing Drink Customer selects coffee or
tea.
Preparing Drink Dispense Drink Drink preparation
completed.
Dispense Drink Idle Drink dispensed.
Waiting for Selection Idle Customer cancel.
5. Draw a State Chart Diagram.

6. Why is it important that the machine returns to Idle after dispensing the drink or after
cancellation.

It is because the machine is ready to use for the next customer. Returning to idle ensures that
the machine reset its process, avoids errors, and maintains correct operation. It also prevents
leftover transactions from affecting new customers.

You might also like