







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lecture was delivered by Dr. Jameel Ahmad at Quaid-i-Azam University for Object Oriented Programming course. It includes: Object, Oriented Programming, Introduction, Model, Syntax, Functional, Procedural, Class, Instance
Typology: Slides
1 / 13
This page cannot be seen from the preview
Don't miss anything!








1
Assist.^ Professor^ Computer
Science, Faculty^ of^ Computing,
Mohammad^ Ali^ JinnahUniversity,^ Islamabad. st^ Office: 113, 1 floor, Block^ A.^ Email:^ [email protected]
2
-^ Functional^
4
Example^
Procedural
Programming
Struct^ BankAccount { double^ balance;int^ accNo;} void^ deposit(BankAccount
acc , amount) {^ acc .balance + = amonut;}^ void^ withdraw^ (BankAccount
acc , amount) {^ acc .balance -^ = amonut;} double getBalance(^ BankAccount
acc ) { cout<<^ acc .aacNo<<
acc .balance; } void^ transferMoney(BankAccount
acc1, BankAccount^ acc2 ) { acc2.balance + = amount;acc1.balance - = amount; }
void^ main^ (void){^ BankAccount^ aliAccount = new
BankAccount ; BankAccount^ assadAccount = new
BankAccount ; //Operations^ on^ ali^ account; deposit( aliAccount ,10000);deposit( aliAccount ,5000);getBalance( aliAccount
); withdraw( aliAccount , 1000) ;getBalance( aliAccount
); //Operations^ on^ assad^ account deposit( assadAccount ,1000);deposit( assadAccount ,5000);getBalance( assadAccount
); withdraw( assadAccount
, 1000); getBalance( assadAccount
); }
5
Example^ Object
Oriented^
Programming
Class^ BankAccount {^ private:double^ balance;int^ accNo;^ public :void^ deposit( double
amount){ balance+= amonut;} void withdraw (double amount){ balance - = amonut;} void getBalance() { cout<<accNo<<balance;} }
void^ main^ void(){ BankAccount^ aliAccount = new
BankAccount() ; BankAccount^ assadAccount = new
BankAccount() ; //Operations^ on^ ali^ account;^ aliAccount.^ deposit( 10000);^ aliAccount.^ deposit( 5000);^ aliAccount.^ getBalance();^ aliAccount.^ withdraw( 1000);^ aliAccount.^ getBalance(); //Operations^ on^ assad^ account;^ assadAccount.^ deposit( 1000);^ assadAccount.^ deposit( 5000);^ assadAccount.^ getBalance();^ assadAccount.^ withdraw( 1000);^ assadAccount.^ getBalance(); }
7
-^ The^ data^ represent
-^ Data^ can^ also
-^ A^ balance
-^ An^ account number
8
Why^ Object
‐Oriented?
- Is^ OO^ A^ New
Imperative^
Procedures^ &^ Algorithms Function‐oriented
Mathematical
functions Logic‐oriented^
Goals,^ predicate
logic Object‐oriented
Classes^ &
Objects Rule‐oriented^
Expert^ systems Constraint‐oriented
Invariant^ relations
-^ Paradigm:
“way^ of^ looking
at^ things”
-^ Yes!^ OO^ does
present^ a^ new
way.
10
All^ about^
to^ implement
“Object^ Model”
-^ Consisting^ of
objects^ and classes. Describes^ what^ will be necessary^ to^ make^ the desired software^ product.
-^ The^ object^ model
is^ the result^ of^ OOA^ and
OOD^ and the^ basis^ for implementation. • There^ exists^ no
standard object^ model • The^ following^ aspects should^ in^ any^ case
be contained^ in^ a^
good^ object model:
TypingAbstractionEncapsulationModularityHierarchyConcurrencyPersistence
11
-^ Typing :^ –^ “It^ is^ the
-^ Abstraction:^ –^ “ An^ abstraction
-^ Encapsulation:^ –^ “It^ is^ the
Object^ implementation” Model^ (Continue…)
13
-^ some^ data,
-^ the^ operations