Skip to content

Instantly share code, notes, and snippets.

@thanoojgithub
Last active December 15, 2015 09:54
Show Gist options
  • Save thanoojgithub/cbcb660d14e85d9cf11e to your computer and use it in GitHub Desktop.
Save thanoojgithub/cbcb660d14e85d9cf11e to your computer and use it in GitHub Desktop.
Employee class using python
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
@thanoojgithub
Copy link
Author

add output as'll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment