class Employee(object): def __init__(self, name, salary=0): self.name = name self.salary = salary def giveRaise(self, percent): self.salary = self.salary + (self.salary * percent) def work(self): print self.name, "does stuff" def resign(self): self.myresign() def __repr__(self): return "" % (self.name, self.salary) class Chef(Employee): def __init__(self, name): Employee.__init__(self, name, 50000) def work(self): print self.name, "makes food" class Server(Employee): def __init__(self, name, counter=1): Employee.__init__(self, name, 40000) self.counter = counter def work(self): print self.name, "interfaces with customer at counter", self.counter def myresign(self): print "I resign you SOB" class PizzaRobot(Chef): def __init__(self, name): Chef.__init__(self, name) def work(self): print self.name, "makes pizza" if __name__ == "__main__": bob = PizzaRobot('bob') # Make a robot named bob. print bob # Runs inherited __repr__ bob.work( ) # Run type-specific action. bob.giveRaise(0.20) # Give bob a 20% raise. print bob; print print "Work:" for klass in Employee, Chef, Server, PizzaRobot: obj = klass(klass.__name__) obj.work( ) print ; print "Resign:" joe = Server('joe') joe.resign()