In: Computer Science
Draw the class diagram for the bank system given the following
specifications:
1.One bank is associated with 0 or more accounts
2. Each account is associated with exactly one bank
3. Current account, savings and money market are account
types.
Show and discuss the different class relations in your diagram.
1.In the below diagram the relationship between bank and accounts is MULTIPLICITY.
Multiplicity allows to specify the cardinality. Bank can have many accounts(that is 0 or more).
Multiplicity | option | Cardinality |
0..0 | 0 | Collection must be empty |
0..1 | No instances or one instance | |
1..1 | 1 | Exactly one instance |
0..* | * | Zero or more instances |
1..* | At least one instance | |
5..5 | 5 | Exactly 5 instances |
m..n | At least m but no more than n instances |
2.In the below diagram the relationship between account and bank is AGGREGATION.
Aggregation is a variant of the "has a" association relationship, aggregation is more specific than association. Aggregation can occur when a class is a collection or container of other classes, but the contained classes do not have a strong life cycle dependency on the container. The contents of the container still exist when the container is destroyed.
To show aggregation in a diagram, draw a line from the parent class to the child class with a diamond shape near the parent class.
3.In the below diagram the relationship between account and account types is GENERALIZATION.
In generalization one class is inherited from another that means
the instance of subclass is also the instance of super
class.
To show inheritance in a UML diagram, a solid line from the child class to the parent class is drawn using an unfilled arrowhead.