Object Oriented Programming
- An object can be anything with
- contents
- capabilities
- Examples
- Bank Account
- contents
- number
- name
- bank info
- contact info
- balance
- capabilities:
- withdraw
- transfer
- contents
- Car
- Contents:
- engine
- seats
- make
- capabilities:
- commute
- drive
- Contents:
- Contents become members and capabilities become methods (functions)
- In python
class BankAccount:
def withdraw(amount: int):
pass
def transfer(amount: int, to: BankAccount):
pass
- Class will have three types of methods
- class methods
- instance methods
- static methods
-
members will also be at levels
- instance members
- class members
-
Objects can be related to each other, we have two major types of relationships
- is-a (inheritence)
- has-a (Composition)
Lets discuss object oriented library
- Library has a catalog
- Catalog will have books which you can
- search by title
- search by id
- Each Book can be loaned (Transaction)
- Loan will have
- Person
- Book
-
Each Book will have a unique id by college
-
Book:
- contents:
- title
- isbn
- author
- genre
- contents:
- Person:
- content:
- id
- name
- mobilenumber
- capability:
- loan
- return
- content:
- Loan:
- contents:
- id
- start_datetime
- end_datetime
- student
- contents:

- Exercise: Try implementing inventory for grocery store.
