Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

TM354: Revision Questions

Apply the DIT, CBO and NOC metrics to the Room class. Assume the class that
has no parent is a direct subclass of the Object class.
Answer:
DIT = 1, CBO = 2 and NOC = 1.

Remember that:
• DIT (Depth-of-inheritance-tree) = number of ancestors + 1
• CBO (Coupling-between-objects) = number of classes associated (linked) with
that class.
• NOC (Number-of-children) = number of immediate children for that class
Apply the DIT, CBO and NOC metrics to the abstract class Account. Assume the
class has no parent is a direct subclass of the Object class.

Answer:
DIT = 1, CBO = 3, NOC = 2
Apply the DIT, CBO and NOC metrics to the Copy class. Assume the class has
no parent is a direct subclass of the Object class.

Answer:
DIT = 1, CBO =1, NOC = 2
State chart diagram
In a ticket reservation system, the seat has four states: Free,
reserved cancelled, and paid. Initially the seat is Free, when
reservation ok, it becomes reserved. If passenger presses cancel,
seat moves to cancelled state, then when it is confirmed it
moves to Free State. When payment is done, seat becomes paid
which is the end of the process.
Q1. Draw a state chart diagram to represent the Seat states.
Answer:
State chart diagram
Q2: What are the benefits of state chart diagrams?
Answer:
1. They are a means of elaborating the potential operations within a
class.
2. They help you understand the behavior of an object over its lifetime.
3. They help you understand how an object or a system must respond
to events.
4. They are a means of ensuring correctness.
State chart diagram
Assume you have the following behavior of a stack object, where 2 operations
could be done on the stack: push(Object b) and pop().
− At the beginning, the stack is Empty.
− If an object is pushed on the top of the stack, it becomes Non-Empty.
− The stack will be in the Non-Empty state until an object is pushed in the
last available space in the stack, and then it becomes Full.
− The opposite of the above scenarios happened with the pop() operation,
which is used to remove an object from the top of the stack.

Q1: Draw a simple state chart diagram that illustrates this behavior.
Q2: Refer to a self-transition in your diagram.
State chart diagram
Answer:
State chart diagram
Q3: List the elements of state chart diagram.
Answer:
States: Boxes with rounded corners
Initial state: Black solid circle
Final state: Black circle surrounding a solid black circle.
Transition: Arrows between states .
[Guard]: Which represents a condition.
Events: Label on a transition such as receiving a message.
Sequence/communication diagrams
Given the following sequence diagram:
Sequence/communication diagrams
Q1: Nominate classes in the figure.

Answer:
A, B, Club, and D

Q2: What are the methods of class Club depending on this diagram?

Answer:
add()
getInfo()
Sequence/communication diagrams
Q3: Convert the diagram into an equivalent collaboration (communication)
diagram.
Answer:

You might also like