# point.py # Walker M. White (wmw2) # 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""" lname = '' # Last name. String. Use '' if it is unknown ssn = 0 # Social security no.; int in range 0..999999999 boss = None # The worker's boss, another Worker object. Use None if none def __init__(self,n,s,b): """Constructor: instance with last name n, soc sec number s, and boss b. Precondition: n is a string; use '' if unknown s is an int in 0..999999999 b is None if this Worker has no boss; otherwise it is another Worker object""" self.lname = n; self.ssn = s; self.boss = b; def __str__(self): """Returns: text representation of this Worker""" return ('Worker ' + self.lname + '. Soc sec XXX-XX-' + str(self.ssn) + ('.' if self.boss is None else '. boss: ' + self.boss.lname))