forked from tdwojak/Python2017
Resolved
This commit is contained in:
parent
a37ec78f22
commit
cf0d9945b9
@ -23,37 +23,60 @@ class Employee():
|
||||
return id
|
||||
|
||||
def __init__(self, name, surname):
|
||||
self.id = Employee.add_id()
|
||||
self.name = name,
|
||||
Employee.add_id()
|
||||
self.id = Employee.id
|
||||
self.name = name
|
||||
self.surname = surname
|
||||
|
||||
def get_id(self):
|
||||
return self.id
|
||||
|
||||
def __repr__(self):
|
||||
return '<Employee, %s, %s %s>' % (self.id,self.name,self.surname)
|
||||
|
||||
|
||||
class Recruiter(Employee):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def __init__(self,name,surname):
|
||||
super().__init__(name,surname)
|
||||
self.recruited=[]
|
||||
|
||||
def recruite(self,Employee):
|
||||
self.recruited.append(self.recruite())
|
||||
return Employee.get_id()
|
||||
self.recruited.append(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()
|
Loading…
Reference in New Issue
Block a user