Object Oriented Programming - Combined
Object Oriented Programming - Combined
Gayathri Namasivayam
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Why use OOP?
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Building Blocks of OOP: Objects &
Classes
● Object: models a
● Real world object (ex. computer, book, box)
● Concept (ex. meeting, interview)
● Process (ex. sorting a stack of papers or comparing two
computers to measure their performance)
created
Introduction to OOP
Building Blocks of OOP: Objects &
Classes
Class has
●
● Set of attributes or properties that describes every object
● Set of behavior or actions that every object can perform
Object has
●
● Set of data (value for each of its attribute)
● Set of actions that it can perform
● An identity
Attributes Behavior
Color: Yellow Start, Accelerate,
Reverse, Stop
Class: FordCar Type: Coupe
Model: Mustang
Attributes Cylinder: 6
Color, Type, Model, Cylinder
Behavior
Start, Accelerate, Reverse, Stop
Object: FordCar2
Attributes Behavior
Color: Orange Start, Accelerate,
Type: Coupe Reverse, Stop
Model: Focus
Cylinder: 4
Introduction to OOP
Another Real World Example..
Object: Person1
Behavior
Speak, Listen, Eat, Run, Walk Object: Person2
Attributes Behavior
Name: Adam Speak,
Listen, Eat,
Height: 5’ 9”
Run, Walk
Age: 24
Introduction to OOP
Class
Introduction to OOP
Class ShippingBox
sender_name : string
receiver_name : string
cost_per_pound : int int shipping_cost() {
weight : int return cost_per_pound*weight;
}
shipping_cost() : int
Introduction to OOP
Object
Introduction to OOP
Objects of ShippingBox class
Object BoxA
sender_name = Julie
receiver_name = Jill
cost_per_pound = 2
weight = 5
shipping_cost()
Class
ShippingBox
Object BoxB
sender_name = Jim
receiver_name = John
cost_per_pound = 5
weight = 10
shipping_cost()
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
What is OOP?
Introduction to OOP
Problem Solving in OOP
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Abstraction
Introduction to OOP
Abstraction
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Encapsulation
●Mechanism by which we combine data and the functions
that manipulate the data into one unit
●Objects & Classes enforce encapsulation
sender_name
receiver_name
cost_per_pound
weight
shipping_cost()
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Inheritance
Introduction to OOP
Inheritance Example
Introduction to OOP
Inheritance Example
BankAccount
customer_name : string
account_type : string
balance : int
deposit() : int
withdrawal() : int
CheckingAccount SavingsAccount
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism*
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Disadvantages of OOP
Introduction to OOP
Conclusion
●Classes & Objects
●Concepts in OOP
● Abstraction
● Encapsulation
● Inheritance
●Advantages & Disadvantages
●Next class
Introduction to OOP
Thank you!
Introduction to OOP