0% found this document useful (0 votes)
18 views11 pages

Lecture 3 - Object Diagrams

Uploaded by

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

Lecture 3 - Object Diagrams

Uploaded by

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

ICT 1411

Object Oriented Programming


Lecture
Object Diagrams
Object Diagram

• An Object diagram shows a set of real objects and their links at a given moment
in the system.
• The attributes identified by the class now have values associated with it.
• There might also be behavior associated with the methods (or operations)
identified by the class.
Object Notation
Notation consists of two compartments:

Top compartment ObjectName: ClassName


(Object name and class name)
AttributeName1 = AttributeValue
AttributeName2 = AttributeValue
Bottom compartment
(Attributes and their values)

• Top compartment contains object name and class name.


• Bottom compartment contains list of attributes names and values:
• No need to show the operations (they are the same for all objects of a class)
Shorter Forms of Notation
• Named Objects objectName : className

• Anonymous Objects
:className
Examples

Employee
emp1: Employee
-employeeId : int
-employeeName : String employeeId = 001
- address : String employeeName = "Amali"
+ displayEmployeeDetails() : void address = "Maharagama"

Employee Class Object called ‘emp1’ from class


‘Employee’
Activity 1
Draw an object diagram for the following class diagram:
Activity 2
Draw an object diagram for the following class diagram:
Activity 3
• Represent the following class diagram as an object diagram.

Company
Person Contract
- companyId : int
- id : int 1..* - contractId : int 1..*
1..1 1..1 - name : String
- Name : String sign - period : float
has - regNo : String
END

You might also like