[OOP] 01 - Objects and Classes
-
OOP: Object Oriented Programming
-
programming that resembles real life
- everything in life is an object
- car, table, computer, fan
- every object in real life has some
- attribute or properties
- behaviours or methods
- everything in life is an object
tv as an object
- attributes of a tv
- model number
- screen size
- behaviour of a tv
- on/off
- brightness increase/reduce
- contrast increase/reduce
- volume increase/reduce
- channel change
objects in programming
- variables (data members) of an object:
- attributes
- functions (methods) of an object:
- behavior
- to define a blank class in python:
class TV: pass
-
code management and reusability increases with OOP
- to create an object from a class
t = TV() print t
features of OOP
- inheritance
- encapsulation
- polymorphism