Advertisement
182days

OOP & Class

Apr 25th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #OOP & Class example
  2.  
  3. class Employee:
  4.    'Common base class for all employees'
  5.    empCount = 0
  6.  
  7.    def __init__(self, name, salary):
  8.       self.name = name
  9.       self.salary = salary
  10.       Employee.empCount += 1
  11.    
  12.    def displayCount(self):
  13.      print ("Total Employee %d" % Employee.empCount)
  14.  
  15.    def displayEmployee(self):
  16.       print ("Name : ", self.name,  ", Salary: ", self.salary)
  17.  
  18. emp1 = Employee("Zara", 2000)
  19. emp2 = Employee("Manni", 5000)
  20. emp3 = Employee("Steve", 9999)
  21. emp1.displayEmployee()
  22. emp2.displayEmployee()
  23. emp3.displayEmployee()
  24. print ("Total Employee %d" % Employee.empCount)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement