You are on page 1of 9

Department of

Computer Science and Engineering

Lab No. 07
Title: Develop UML Class Diagram for The
Given Project

Software Engineering Lab


CSE 314

Green University of Bangladesh


1 Objective(s)
• To depict various aspects of the OOPs concept using Class Diagram.

1.1 Sub-Objective(s)
• To describe the static view of the system.
• To model the collaboration among the elements of the static view.
• To describe the functionalities performed by the system.
• To construct software applications using object oriented languages.
• To perform code forward engineering for the target systems.
• To classify classes or components as library for future reuses.

2 Problem analysis
Most of the UML diagrams can not be mapped directly with any object-oriented programming languages except
class diagrams. In other words, class diagram ideally can have one to one mapping to UML class diagrams.
Class diagrams are the main building blocks of every object-oriented method. The class diagram can be used to
show the classes, relationships, interface, association, and collaboration. UML is standardized in class diagrams.
Since classes are the building block of an application that is based on OOPs, so as the class diagram has an
appropriate structure to represent the classes, inheritance, relationships, and everything that OOPs have in
their context. It describes various kinds of objects and the static relationship between them.
Problem statement and motivation for the given project: The project entitled Banking ATM
system has a drastic change to that of the older version of banking system, customer feel inconvenient with
the transaction method as it was in the hands of the bank employees. In our ATM system, the above problem
is overcome here, the transactions are done in person by the customer thus makes the customers feel safe and
secure.Thus the application of our system helps the customer in withdrawing money, checking the balance
and transaction of the amount with mini-statement and transferring the balance by validating the pin number
therefore ATM system is more user friendly.

3 Methodology
There are several diagram components that can be efficiently used while making/editing the model. These are
as follows:
• Class name, attribute, method
• Objects
• Interface
• Relationships inheritance, association, generalization
• Associations bidirectional, unidirectional
There are several points to be kept in focus while drawing the class diagram. These can be said as its syntax:
Each class is represented by a rectangle having a subdivision of three compartments name, attributes, and
operations (methods and constructors).
There are three types of modifiers that are used to decide the visibility of attributes and operations.
+ is used for public visibility(for everyone)
# is used for protected visibility (for friend and derived)
– is used for private visibility (for only me)
To draw an UML Class Diagram of a system we have to use some symbols and notations are described
below.

(a) Class: The UML representation of a class is a rectangle containing three compartments Name, Attributes
and Operations stacked vertically, as shown in the Fig.1.

© Dept. of Computer Science and Engineering, GUB


Class Name

Figure 1: Symbols of a class

• Name- Class name is placed on the top block with middle alignment of a class starting with a capital
letter.
• Attribute- The attribute section of a class lists each of the class’s attributes on a separate line. The
attribute section is optional, but when used it contains each attribute of the class displayed in a list
format. The line uses this format: name : attribute type (e.g. cardNumber : Integer).
• Operation- The operations are documented in the bottom compartment of the class diagram’s rectangle,
which also is optional. Like the attributes, the operations of a class are displayed in a list format, with
each operation on its own line. Operations are documented using this notation: name (parameter list) :
type of value returned (e.g. calculateTax (Country, State) : Currency).

(b) Relationships: There are different types of relationships in the class diagram are described below.

• Association- Some objects are made up of other objects. Association specifies a "has-a" or "whole/part"
relationship between two classes. In an association relationship, an object of the whole class has objects
of part class as instance data.
In a class diagram, an association relationship is rendered as a directed solid line. There are two types of
associations, Unidirectional and Bidirectional association as shown in Fig.2

Unidirectional association

Bidirectional (standard) association

Figure 2: Symbols of Associations

Unidirectional association - In a unidirectional association, two classes are related, but only one class
knows that the relationship exists.
A unidirectional association is drawn as a solid line with an open arrowhead pointing to the known class.
Bidirectional (standard) association - An association is a linkage between two classes. Associations are
always assumed to be bi-directional; this means that both classes are aware of each other and their
relationship, unless you qualify the association as some other type.
A bi-directional association is indicated by a solid line between the two classes.

© Dept. of Computer Science and Engineering, GUB


• Multiplicity- Place multiplicity notations near the ends of an association. These symbols indicate the
number of instances of one class linked to one instance of the other class. For example, one company will
have one or more employees, but each employee works for one company only as shown in Fig.3.

Figure 3: Symbols of Multiplicity

• Visibility- Visibility is used to signify who can access the information contained within a class denoted
with +, -, and as shown in Fig.4.

Figure 4: Symbols of Visibility

• Generalization- A generalization is a relationship between a general thing (called the superclass) and a
more specific kind of that thing (called the subclass). Generalization is sometimes called an "is a kind of"
relationship and is established through the process of inheritance.
In a class diagram, generalization relationship is rendered as a solid directed line with a large open
arrowhead pointing to the parent class as shown in Fig.5.
• Abstract Classes and methods- In an inheritance hierarchy, subclasses implement specific details, whereas
the parent class defines the framework its subclasses. The parent class also serves a template for common
methods that will be implemented by its subclasses. Fig.6 shows the abstract class and methods.

© Dept. of Computer Science and Engineering, GUB


Figure 5: Symbols of Generalization

Figure 6: Symbols of Abstract Class and Methods

The name of an abstract Class is typically shown in italics; alternatively, an abstract Class may be shown
using the textual annotation, also called stereotype abstract after or below its name.
An abstract method is a method that do not have implementation. In order to create an abstract method,
create a operation and make it italic.

• Realization- A realization is a relationship between two things where one thing (an interface) specifies a
contract that another thing (a class) guarantees to carry out by implementing the operations specified in
that contract.
In a class diagram, realization relationship is rendered as a dashed directed line with an open arrowhead
pointing to the interface as shown in Fig.7.
.
• Dependency- Dependency indicates a "uses" relationship between two classes. In a class diagram, a
dependency relationship is rendered as a dashed directed line as shown in Fig.8.
.
If a class A "uses" class B, then one or more of the following statements generally hold true:

– Class B is used as the type of a local variable in one or more methods of class A.
– Class B is used as the type of parameter for one or more methods of class A.
– Class B is used as the return type for one or more methods of class A.
– One or more methods of class A invoke one or more methods of class B.

• Package- You can draw packages for logical categorization of classes as shown in Fig.9.
.

© Dept. of Computer Science and Engineering, GUB


<<interface>>
IShap

Figure 7: Symbols of Realization

Figure 8: Symbols of Dependency

Figure 9: Symbols of Packages

© Dept. of Computer Science and Engineering, GUB


3.1 Required Software
There are several software available that can be used online and offline to draw these class diagrams Like as
follows.
1. Visual Paradigm for UML 8.2 (online link: https://online.visual-paradigm.com/)
2. StartUML
3. Lucidchart and other drawing tools

3.2 Procedure
You can draw class diagrams in VP-UML. A class diagram describes the structure of an object-oriented system
by showing the classes in that system and the relationships between the classes. A class diagram also shows
constraints, and attributes of classes. Go through the following link and follow procedure step by step to draw
a class diagram.
https://www.visual-paradigm.com/support/documents/vpuserguide/94/2576/7190d rawingclass.html

4 Implementation
The Class diagram of the Banking ATM system is shown in Fig.10.

5 Output
Example Java code for class Withdrawal based on Fig.10 is given below.
1 // Class Withdrawal represents an ATM withdrawal transaction
2 public class Withdrawal
3 {
4 // attributes
5 private int accountNumber; // account to withdraw funds from
6 private double amount; // amount to withdraw
7
8 // references to associated objects
9 private Screen screen; // ATM’s screen
10 private Keypad keypad; // ATM’s keypad
11 private CashDispenser cashDispenser; // ATM’s cash dispenser
12 private BankDatabase bankDatabase; // account info database
13
14 // no−argument constructor
15 public Withdrawal()
16 {
17 } // end no−argument Withdrawal constructor
18
19 // operations
20 public void execute()
21 {
22 } // end method execute
23 } // end class Withdrawal

Example Java code for class Keypad based on Fig.10 is given below.
1 // Class Keypad represents an ATM’s keypad
2 public class Keypad
3 {
4 // no attributes have been specified yet
5
6 // no−argument constructor
7 public Keypad()
8 {
9 } // end no−argument Keypad constructor

© Dept. of Computer Science and Engineering, GUB


10
11 // operations
12 public int getInput()
13 {
14 } // end method getInput
15 } // end class Keypad

Figure 10: Class diagram of the Banking ATM system

© Dept. of Computer Science and Engineering, GUB


6 Discussion & Conclusion
Based on the focused objective(s) to understand about UML sequence diagram, the additional lab exercise made
me more confident towards the fulfilment of the objectives(s). This class diagram is a structural UML model.
Since it provides detailed information about the properties and interfaces of the classes, it can be considered as
the main model and regard the other UML diagrams as supplementary models.

7 Lab Task (Please implement yourself and show the output to the
instructor)
1. Draw a class diagram for the given project ‘Library Management System’.

7.1 Problem analysis


A library database system is an infrastructure that allows users to search books and book content, add/remove,
and download selected books. The problem faced is that library users require an efficient method to find
a specific book or keyword(s) within a book given a continuously expanding library. Some scenarios of the
‘Library Management System’ are as follows:
1. User who registers himself as a new user initially is regarded as staff or student for the library system.
(i) For the user to get registered as a new user, registration forms are available that is needed to be fulfilled
by the user.
(ii) After registration, a library card is issued to the user by the librarian. On the library card, an ID is
assigned to cardholder or user.
2. After getting the library card, a new book is requested by the user as per there requirement.
3. After, requesting, the desired book or the requested book is reserved by the user that means no other
user can request for that book.
4. Now, the user can renew a book that means the user can get a new due date for the desired book if the
user has renewed them.
5. If the user somehow forgets to return the book before the due date, then the user pays fine. Or if the
user forgets to renew the book till the due date, then the book will be overdue and the user pays fine.
6. User can fill the feedback form available if they want to.
7. Librarian has a key role in this system. Librarian adds the records in the library database about each
student or user every time issuing the book or returning the book, or paying fine.
8. Librarian also deletes the record of a particular student if the student leaves the college or passed out from
the college. If the book no longer exists in the library, then the record of the particular book is also deleted.
9. Updating database is the important role of Librarian.

8 Lab Exercise (Submit as a report)


• Draw an Class diagram for the given project for your team.

9 Policy
Copying from internet, classmate, seniors, or from any other source is strongly prohibited. 100% marks will be
deducted if any such copying is detected.

© Dept. of Computer Science and Engineering, GUB

You might also like