Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #OOP & Class example
- class Employee:
- 'Common base class for all employees'
- empCount = 0
- def __init__(self, name, salary):
- self.name = name
- self.salary = salary
- Employee.empCount += 1
- def displayCount(self):
- print ("Total Employee %d" % Employee.empCount)
- def displayEmployee(self):
- print ("Name : ", self.name, ", Salary: ", self.salary)
- emp1 = Employee("Zara", 2000)
- emp2 = Employee("Manni", 5000)
- emp3 = Employee("Steve", 9999)
- emp1.displayEmployee()
- emp2.displayEmployee()
- emp3.displayEmployee()
- print ("Total Employee %d" % Employee.empCount)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement