Object Oriented Programming
description
Transcript of Object Oriented Programming
![Page 1: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/1.jpg)
Object Oriented Programming
![Page 2: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/2.jpg)
Object OrientedData and operations are grouped together
AccountWithdrawDepositTransfer
Interface:
Set of available operations
![Page 3: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/3.jpg)
Data Encapsulationclass Account { private float balance;
public float withdraw(); public void deposit(float amount); }
![Page 4: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/4.jpg)
Objects and ClassesClasses reflect concepts, objects reflect instances that embody those concepts.
Pooja Monica SrutiPriya
girlclassobject
![Page 5: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/5.jpg)
Objects and Classes cont’dA class captures the common properties of the objects instantiated from itA class characterizes the common behavior of all the objects that are its instances
![Page 6: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/6.jpg)
Objects and Classes cont’dClass BankAccountBalanceInterestYTDOwnerAccount_number
Balance 500InterestYTDOwner Account_number
Balance 10,000InterestYTDOwner Account_number
OperationsMakeDesposit
Transfer
WithDraw
GetBalance
![Page 7: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/7.jpg)
Objects as instances of Classes
The world conceptually consists of objectsMany objects can be said to be of the same type or class My bank account, your bank account, Bill
Gates’ bank account …We call the object type a class
![Page 8: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/8.jpg)
Objects and ClassesClass Visible in
source code The code is not
duplicated
Object Own copy of
data Active in
running program
Occupies memory
Has the set of operations given in the class
![Page 9: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/9.jpg)
Classification
Checking Account
Value First Select Access First Interest
Savings Account
Account
![Page 10: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/10.jpg)
InheritanceA class which is a subtype of a more general class is said to be inherited from it.The sub-class inherits the base class’ data members and member functions
![Page 11: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/11.jpg)
Inheritance cont’dA sub-class has all data members of its base-class plus its ownA sub-class has all member functions of its base class (with changes) plus its ownInheritance is meant to implement sub-typing (don’t abuse it)
![Page 12: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/12.jpg)
AbstractionManagement of complexityHierarchical classification:
is-a relationship: inheritancehas-a relationship: containment
![Page 13: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/13.jpg)
Design an Object Oriented ATM
![Page 14: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/14.jpg)
We will design and perform our own role play with objects
What classes do we need?– Display– Cash Dispenser– Card Reader– Bank Account– Others???
![Page 15: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/15.jpg)
• What methods do we need? On which classes?– Make deposit– Make withdrawal– Balance Inquiry– Dispense cash– Others???????????
![Page 16: Object Oriented Programming](https://reader036.fdocuments.us/reader036/viewer/2022062400/56815b2a550346895dc8ef0a/html5/thumbnails/16.jpg)