Professional Documents
Culture Documents
Lab Manual 07 CSE 314 Class Diagram
Lab Manual 07 CSE 314 Class Diagram
Lab No. 07
Title: Develop UML Class Diagram for The
Given Project
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.
• 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
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.
• Visibility- Visibility is used to signify who can access the information contained within a class denoted
with +, -, and as shown in Fig.4.
• 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.
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.
.
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
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’.
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.