Lecture 3 - OOP Concepts.pptx
Lecture 3 - OOP Concepts.pptx
1-1
Lecture 3
Lecture Overview
Chapter 1. Introduction to OOP Concepts
1-2
Abstraction
Attributes
- Name - Employee ID
- Student Roll No - Designation
- Year of Study - Salary
- CGPA - Age
Example – Abstraction
Behavior
- Study - DevelopExam
- GiveExam - TakeExam
- PlaySports - Eat
- DeliverLecture - Walk
Example – Abstraction
Engineer’s View
Driver’s View
Abstraction – Advantages
(Class Name)
(Class Name)
(attributes)
Suppressed Form
(operations)
Normal Form
Example – Graphical Representation of Classes
Circle
center Circle
radius
Suppressed Form
draw
computeArea
Normal Form
Example – Graphical Representation of Classes
Person
name Person
age
gender Suppressed Form
eat
walk
Normal Form
Inheritance
Inheritance in Classes
Person
Student Doctor
Teacher
Example – Inheritance
Shape
Line Triangle
Circle
Inheritance – “IS A” or
“IS A KIND OF” Relationship
Person
name
age
gender
eat
walk
Shape
color
coord
draw
rotate
setColor
Circle Triangle
radius Line angle
draw length draw
computeArea draw computeArea
Inheritance – Advantages
❑ Reuse
❑ Less redundancy
❑ Increased maintainability
Reuse with Inheritance
Main purpose of inheritance is reuse
Shape
color
coord
draw
rotate
setColor
Circle Triangle
radius Line angle
draw length draw
computeArea draw computeArea
Example Reuse
name
age
gender
eat
walk
Person
name
age
gender
eat
walk