def __init__(self, name): Employee.__init__(self, name, 40000) def work(self): print(self.name, "interfaces with customer") 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) # Run inherited __repr__ bob.work() # Run type-specific action bob.giveRaise(0.20) # Give bob a 20% raise print(bob); print() for klass in Employee, Chef, Server, PizzaRobot: obj = klass(klass.__name__) obj.work() C:\python\examples> python employees.py ### file: pizzashop.py from employees import PizzaRobot, Server
Employee.__init__ (self, name, 40000) def work(self): print(self.name, "interfaces with customer") # взаимодействует # с клиентом 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') # Создать робота по имени bob print (bob) # Выполняется унаследованный метод__ repr__ bob.work () # Выполняется действие, специфичное для типа bob.giveRaise (0.20) # Повысить зарплату роботу bob на 20% print(bob); print() for klass in Employee, Chef, Server, PizzaRobot: obj = klass(klass.__name__ ) obj.work() ______________________________________________________________ from __future__ import print_function from employees import PizzaRobot, Server class Customer: def __init__ (self, name): self.name = name def order(self, server): print(self.name, "orders from", def pay(self, server): print(self.name, class Oven: