Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Employee:
- 'Common base class for all employees'
- empCount = 0
- #object constructor with arguments
- def __init__(self, name, salary):
- self.name = name
- self.salary = salary
- Employee.empCount += 1 #predefined function/work during creation of object instance
- def displayCount(self):
- print("Total Employee {}".format(Employee.empCount))
- def displayEmployee(self):
- print("Name: {0}, Salary: {1}".format(self.name,self.salary))
- "This would create first object of Employee class"
- emp1 = Employee("Zara", 2000)
- "This would create second object of Employee class"
- emp2 = Employee("Manni", 5000)
- emp1.displayEmployee()
- emp2.displayEmployee()
- print("Total Empolyee {}".format(Employee.empCount))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement