0% found this document useful (0 votes)
2 views

2-COE312 Lecture - Class diagrams

The document explains class diagrams, which depict classes and their relationships in a static view of an application. It details the structure of a class, including its name, attributes, and methods, as well as visibility modifiers like public, protected, and private. Additionally, it discusses relationships such as generalization, association, aggregation, and composition, along with access and non-access modifiers for class attributes and methods.

Uploaded by

toshionoeiyu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

2-COE312 Lecture - Class diagrams

The document explains class diagrams, which depict classes and their relationships in a static view of an application. It details the structure of a class, including its name, attributes, and methods, as well as visibility modifiers like public, protected, and private. Additionally, it discusses relationships such as generalization, association, aggregation, and composition, along with access and non-access modifiers for class attributes and methods.

Uploaded by

toshionoeiyu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Class Diagram

and Modifiers
Omar Arif
 A Class diagram depicts classes and
their relationships
Class
 It depicts a static view of an
Diagram
application
Customer

Rental Invoice

Class Rental Item

Diagram

Checkout Screen
Bicycles E. Scooter Tricycle
 Each class is represented by a rectangle
subdivided into three compartments
Name
Attributes/Fields
Methods

Class  Modifiers are used to indicate visibility of


attributes and operations.
Diagram ‘+’ is used to denote Public visibility
(everyone)
‘#’ is used to denote Protected visibility
(subclasses)
‘-’ is used to denote Private visibility (no
one)
Name
Account_Name
- Customer_Name
Attributes
- Balance
Class +addFunds( ) Operations
Diagram +withDraw( )
+transfer( )
 There are two kinds of Relationships
Generalization (parent-child relationship)
Association (student enrolls in course)

Relationship  Associations can be further classified


s as
Aggregation
Composition
 A generalization is a relationship between a parent
class (superclass) and a child class (subclass). In
this relationship, the child class inherits properties
and behaviors from a parent class.

Generalizati Example:
Animal
on
Relationship <<Interface>>
Pet Mammal
s

Cat Dog
 It represents a has-a relationship between two
classes, where one class is associated with
another class.
 Student enrolls in a course
 Courses have students
 Courses have exams
Student Course
Association
Relationship
 Associations can be further classified
as
Aggregation
Composition
 Aggregation is a type of association that
represents a whole-part relationship between two
classes, where one class is the owner of another
class, but the contained class can exist
independently of the owning class.
Aggregation
 The composition is a strong type of association,
where one class is made up of one or more
instances of other classes. It portrays the
Composition dependency relationship, where the lifetime of the
contained class is dependent on the owning class.
Customer
Aggregation
Class

Rental Invoice
Abstract
Class

Class <<abstract>>

Diagram
Rental Item

Composition Simple
Generalization Association

Checkout Screen
Bicycle Quad Bike Dune Buggy
 Access Modifier
 public: class is accessible for any
Modifiers: class
Class  Default: class is only accessible
by classes in the same package
 Non-Access Modifier
 final: attributes and method
cannot be overridden/modified
Modifiers:  static: only permissible for nested
Class classes
 abstract: Can only be used in an
abstract class, and can only be
used on methods
 Access Modifiers:
 public: accessible from all classes
 private: accessible from within
class
Modifiers:  protected: accessible from same
method and package and subclasses
attributes  default: accessible from same
package
 Non-Access Modifiers:
 final: cannot be
overridden/modified
Modifiers:  static: Attributes and methods
method and belongs to the class, rather than
an object
attributes
 abstract: Can only be used in an
abstract class, and can only be
used on methods

You might also like