#!/usr/bin/env python2 # -*- coding: utf-8 -*- class Employee(object): NEXT_ID = 0 def __init__(self, name, surname): self.name = name self.surname = surname self.id = Employee.NEXT_ID Employee.NEXT_ID = Employee.NEXT_ID + 1 def get_id(self): return self.id class Recruiter(Employee): def __init__(self, name, surname): super(Recruiter, self).__init__(name, surname) self.recruited = [] def recruit(self, employee): self.recruited.append(employee.get_id()) class Programmer(Employee): def __init__(self, name, surname, recruiter): super(Programmer, self).__init__(name, surname) self.recruiter = recruiter.get_id() empl1 = Employee('a', 'a') empl2 = Employee('b', 'b') rec1 = Recruiter('c', 'c') prog1 = Programmer('d', 'd', rec1) rec1.recruit(prog1) assert prog1.recruiter == rec1.get_id() assert any( recruitee_id == prog1.get_id() for recruitee_id in rec1.recruited )