# worker.py # Walker M. White (wmw2), Steve Marschner (srm2) # October 7, 2012 """Module with a simple Worker class. Class demonstrates fields and a constructor.""" class Worker(object): """Instance is a worker in a certain organization Instance variables: lname [str]: Last name. ssn [int] Social security no. (in 0..999999999) boss [Worker] The worker's boss. Use None if no boss. """ def __init__(self, lname, ssn, boss): """Constructor: instance with last name n, soc sec number s, and boss b. Precondition: lname is a string ssn is an int in 0..999999999 boss is another Worker object or None' """ self.lname = lname self.ssn = ssn self.boss = boss def __str__(self): """Returns: text representation of this Worker""" return ('Worker ' + self.lname + '. Soc sec XXX-XX-' + str(self.ssn % 10000) + ('.' if self.boss is None else '. boss: ' + self.boss.lname))