CLASSDIAGRAMLAB1
CLASSDIAGRAMLAB1
A UML class diagram is a visual tool that represents the structure of a system by showing its
classes, attributes, methods, and the relationships between them. It helps everyone involved in a
project—like developers and designers—understand how the system is organized and how its
components interact
What are class Diagrams?
Class diagrams are a type of UML (Unified Modeling Language) diagram used in software
engineering to visually represent the structure and relationships of classes within a system i.e. used
to construct and visualize object-oriented systems.
In these diagrams, classes are depicted as boxes, each containing three compartments for the class name,
attributes, and methods. Lines connecting classes illustrate associations, showing relationships such as
one-to-one or one-to-many.
Class diagrams provide a high-level overview of a system’s design, helping to communicate and document the
structure of the software. They are a fundamental tool in object-oriented design and play a crucial role in the
software development lifecycle.
What is a class?
In object-oriented programming (OOP), a class is a blueprint or template for creating objects. Objects are
instances of classes, and each class defines a set of attributes (data members) and methods (functions or
procedures) that the objects created from that class will possess. The attributes represent the characteristics or
properties of the object, while the methods define the behaviors or actions that the object can perform.
● The name of the class is typically written in the top compartment of the class box and
2. Attributes:
● Attributes, also known as properties or fields, represent the data members of the
class. They are listed in the second compartment of the class box and often include
the visibility (e.g., public, private) and the data type of each attribute.
3. Methods:
functionality of the class. They are listed in the third compartment of the class box
and include the visibility (e.g., public, private), return type, and parameters of each
method.
● Visibility notations indicate the access level of attributes and methods. Common
package)
***********************************************
1 Online Railway Ticket Reservation System
Online Railway ticket reservation is very useful nowadays. This is very
required ticket(s).
generate the ticket and PNR no. will be given to the passenger.
The System also keeps the payment details and sends them to
4. The Passenger can check PNR status (confirmed, RAC, waiting
5. The Reservation system should store all train details, fare details
(by zone, class, and date wise), PNR no, date of trains, etc. This
6. The System also has refund rules which have a date of
and a cancel ticket request. After cancelation, the Admin will pass
the refundable amount to the System and the System will give
Class Diagram:
PNR_no, status,
payment type, train code
search train,
ticket new Ticket, delete tickets
date of journey
railway
reservation system response
system
formDetails,
Admin ID, name cancellationForm,
refundAmt
2 Class Diagram of Hospital Management System:
Class Diagram for Hospital Management System simply describes structure
of Hospital Management System class, attributes, methods or operations,
relationship among objects.
For a Hospital Management System (HMS), the class diagram and its
characteristics would typically include:
1. Classes: Representing entities such as Patient, Doctor, Nurse,
Billing.
properties. For example, the Patient class might have attributes like
relationship.
departments.
8. Dependency: This would show when one class relies on another
We can start with the Bank class. The bank needs a code to identify it and an
address. The methods that the bank class can use to interact with its ATM are
manage and maintain.
Let’s imagine that the customer can perform two different types of
transactions. They can withdraw funds or they can transfer funds to
another account.
It is also worth bearing in mind that the product is bought and sold for money,
which leads to the payment process. In addition, since we are talking about online
commerce, the shipping process is set up separately.
The purchase and delivery of a product in an online shopping system are usually
arranged as one order attached to the buyer.
Online Shopping
UML Class Diagram Example
Here we provide an example of UML class diagram which shows a domain model
for online shopping. The purpose of the diagram is to introduce some common
terms, "dictionary" for online shopping - Customer, Web User, Account, Shopping
Cart, Product, Order, Payment, etc. and relationships between. It could be used as
a common ground between business analysts and software developers.
Each customer has unique id and is linked to exactly one account. Account owns
shopping cart and orders. Customer could register as a web user to be able to buy
items online. Customer is not required to be a web user because purchases could
also be made by phone or by ordering from catalogues. Web user has login name
which also serves as unique id. Web user could be in several states - new, active,
temporary blocked, or banned, and be linked to a shopping cart. Shopping cart
belongs to account.
Online shopping domain UML class diagram example.
Account owns customer orders. Customer may have no orders. Customer orders
are sorted and unique. Each order could refer to several payments, possibly none.
Every payment has unique id and is related to exactly one account.
Each order has current order status. Both order and shopping cart have line items
linked to a specific product. Each line item is related to exactly one product. A
product could be associated to many line items or no item at all.