Class Employee with a static method. : Static : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Static »

 

Class Employee with a static method.


class Employee:
   numberOfEmployees = 
   maxEmployees = 10     

   def isCrowded():
      return Employee.numberOfEmployees > Employee.maxEmployees

   isCrowded = staticmethodisCrowded )

   def __init__self, firstName, lastName ):
      self.first = firstName
      self.last = lastName
      Employee.numberOfEmployees += 1

   def __del__self ):
      Employee.numberOfEmployees -= 1      

   def __str__self ):
      return "%s %s" self.first, self.last )


answers = "No""Yes" 
employeeList = []         

print answersEmployee.isCrowded() ]

for i in range11 ):
   employeeList.appendEmployee"John""Doe" + str) ) )

   print "Employees are crowded?",
   print answersemployeeList].isCrowded() ]

del employeeList]

print "Employees are crowded?", answersEmployee.isCrowded() ]



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Static