Last active
December 15, 2015 09:54
-
-
Save thanoojgithub/cbcb660d14e85d9cf11e to your computer and use it in GitHub Desktop.
Employee class using python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee(): | |
'Common base class for all employees' | |
empCount = 0 | |
def __init__(self, eid, name, salary, did): | |
self.eid = eid | |
self.name = name | |
self.salary = salary | |
self.did = did | |
Employee.empCount += 1 | |
def displayEmployee(self): | |
print ("eid : ", self.eid,", Name : ", self.name, ", Salary: ", self.salary, ", did: ", self.did) | |
"This would create first object of Employee class" | |
emp1 = Employee(1,"Zara", 2000,10) | |
"This would create second object of Employee class" | |
emp2 = Employee(2,"meera", 4000,20) | |
emp1.displayEmployee() | |
emp2.displayEmployee() | |
print ("Total Employee %d" % Employee.empCount) | |
# OUTPUT :: | |
# | |
# eid : 1 , Name : Zara , Salary: 2000 , did: 10 | |
# eid : 2 , Name : meera , Salary: 4000 , did: 20 | |
# Total Employee 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add output as'll