-
Notifications
You must be signed in to change notification settings - Fork 0
/
employees.py
31 lines (25 loc) · 1001 Bytes
/
employees.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Program used to count the number of employees"""
def main():
class Employee:
'Common base class for all employees'
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
#count total number of employees
Employee.empCount += 1
def displayCount(self):
#prints final number of total employees
print ("Total Employee %d" % Employee.empCount)
def displayEmployee(self):
#prints each employee's name and salary
print ("Name : ", self.name, ", Salary: ", 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 Employee %d" % Employee.empCount)
if __name__ == '__main__':
main()