forked from tdwojak/Python2017
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
#!/usr/bin/env python2
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#!/usr/bin/env python2
|
|
# -*- coding: utf-8 -*-
|
|
from random import randint
|
|
|
|
|
|
class Employee:
|
|
|
|
def __init__(self, imie, nazwisko):
|
|
self.imie = imie
|
|
self.nazwisko = nazwisko
|
|
self.id = randint(0, 1000) # pole nie jest statyczne, nie rozumiem, dlaczego milo by byc
|
|
|
|
def get_id(self):
|
|
return self.id
|
|
|
|
class Recruiter(Employee):
|
|
|
|
def __init__(self, imie, nazwisko):
|
|
super(Recruiter,self).__init__(imie, nazwisko)
|
|
self.recruited = []
|
|
|
|
|
|
def recruit(self, employee):
|
|
if isinstance(employee, Employee):
|
|
self.recruited.append(employee.get_id())
|
|
|
|
|
|
class Programmer(Employee):
|
|
|
|
def __init__(self, imie, nazwisko, recruiter):
|
|
super(Programmer, self).__init__(imie, nazwisko)
|
|
if isinstance(recruiter, Recruiter):
|
|
self.recruiter = recruiter.get_id()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
employee = Employee("Agnieszka", "Wisniewska")
|
|
print(employee.get_id())
|
|
|
|
recruiter = Recruiter("Krzysztof", "Wisniewski")
|
|
recruiter.recruit(employee)
|
|
print(recruiter.get_id())
|
|
print(recruiter.recruited)
|
|
|
|
programmer = Programmer("Ksawery", "Wisniewski", recruiter)
|
|
print(programmer.recruiter) |