1
0
forked from tdwojak/Python2017
This commit is contained in:
Przemysław Kaczmarek 2017-12-14 18:09:05 +01:00
parent a37ec78f22
commit cf0d9945b9

View File

@ -23,37 +23,60 @@ class Employee():
return id return id
def __init__(self, name, surname): def __init__(self, name, surname):
self.id = Employee.add_id() Employee.add_id()
self.name = name, self.id = Employee.id
self.name = name
self.surname = surname self.surname = surname
def get_id(self): def get_id(self):
return self.id return self.id
def __repr__(self):
return '<Employee, %s, %s %s>' % (self.id,self.name,self.surname)
class Recruiter(Employee): class Recruiter(Employee):
def __init__(self): def __init__(self,name,surname):
super().__init__() super().__init__(name,surname)
self.recruited=[]
def recruite(self,Employee): def recruite(self,Employee):
self.recruited.append(self.recruite()) self.recruited.append(Employee.get_id())
return Employee.get_id()
def __repr__(self):
return '<Recruiter, %s, %s %s>' % (self.id, self.name, self.surname)
class Programmer(Employee):
def __init__(self,name,surname,Recruiter):
super().__init__(name,surname)
self.recruiter = Recruiter.get_id()
def __repr__(self):
return '<Programmer, %s, %s %s>' % (self.id, self.name, self.surname)
def TestFunction():
pracownik_przemek=Employee('Przemyslaw','Kaczmarek')
print(pracownik_przemek.name,pracownik_przemek.surname)
pracownik_michal=Employee('Michał','Kowalski')
rekruter_mariusz=Recruiter('Mariusz','Małysz')
programista_adam=Programmer('Adam','Kowalski',rekruter_mariusz)
rekruter_maciej=Recruiter('Maciej','Fisko')
rekruter_maciej.recruite(pracownik_przemek)
rekruter_maciej.recruite(rekruter_mariusz)
rekruter_mariusz.recruite(programista_adam)
rekruter_mariusz.recruite(pracownik_michal)
print('Maciej zrekrutowal: ',rekruter_maciej.recruited)
print('Mariusz zrekrutowal: ',rekruter_mariusz.recruited)
print('Adam zostal zrekrutowany przez: ',programista_adam.recruiter)
print('Liczba pracownikow: ',Employee.id)
print(pracownik_przemek)
print(pracownik_michal)
print(rekruter_mariusz)
print(programista_adam)
print(rekruter_maciej)
TestFunction()
class Programmer(Recruiter):
pass
def main():
print(Employee.id)
adam=Employee('Adam','Kaczmarek')
print(adam.get_id())
print(Employee.id)
michal=Employee('Michal','Kaczmarek')
print(Employee.id)
print(michal.get_id())
michalHR = Recruiter('Michal','Kowalski')
main()