1 / 16

Object Oriented Programming

Object Oriented Programming. Data and operations are grouped together. Object Oriented. Account. Interface: Set of available operations. Withdraw Deposit Transfer. Data Encapsulation. class Account { private float balance; public float withdraw();

sanura
Download Presentation

Object Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Programming

  2. Data and operations are grouped together Object Oriented Account Interface: Set of available operations Withdraw Deposit Transfer

  3. Data Encapsulation class Account { private float balance; public float withdraw(); public void deposit(float amount); }

  4. Pooja Sruti Monica Priya Objects and Classes • Classes reflect concepts, objects reflect instances that embody those concepts. object class girl

  5. Objects and Classes cont’d • A class captures the common properties of the objects instantiated from it • A class characterizes the common behavior of all the objects that are its instances

  6. Objects and Classes cont’d Operations MakeDesposit Transfer WithDraw GetBalance Class BankAccount Balance InterestYTD Owner Account_number Balance 500 InterestYTD Owner Account_number Balance 10,000 InterestYTD Owner Account_number

  7. Objects as instances of Classes • The world conceptually consists of objects • Many 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

  8. Class 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 Objects and Classes

  9. Account Checking Account Savings Account Value First Select Access First Interest Classification

  10. Inheritance • A 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

  11. Inheritance cont’d • A sub-class has all data members of its base-class plus its own • A sub-class has all member functions of its base class (with changes) plus its own • Inheritance is meant to implement sub-typing (don’t abuse it)

  12. Abstraction • Management of complexity • Hierarchical classification: • is-a relationship: inheritance • has-a relationship: containment

  13. Design an Object Oriented ATM

  14. We will design and perform our own role play with objects What classes do we need? • Display • Cash Dispenser • Card Reader • Bank Account • Others???

  15. What methods do we need? On which classes? • Make deposit • Make withdrawal • Balance Inquiry • Dispense cash • Others???????????

More Related