1
0
forked from tdwojak/Python2017

task02 (labs04) done

This commit is contained in:
Ewelina 2017-12-10 11:42:45 +01:00
parent 9c0e6ccc52
commit 84f0d5479f

View File

@ -11,12 +11,14 @@
class Employee(object): class Employee(object):
id = 0 id = 0
lista_id = []
def __init__(self, name, surname): def __init__(self, name, surname):
self.name = name self.name = name
self.surname = surname self.surname = surname
self.id = Employee.id self.id = Employee.id
Employee.id += 1 Employee.id += 1
self.lista_id.append(self.id)
def get_id(self): def get_id(self):
return(self.id) return(self.id)
@ -32,7 +34,10 @@ class Recruiter(Employee):
def recruit(self, id): def recruit(self, id):
if id != self.id: if id != self.id:
if id in Employee.lista_id:
self.recruited.append(id) self.recruited.append(id)
else:
print('Nie ma takiego pracownika!')
else: else:
print('Rekruter nie może zrekrutować samego siebie!') print('Rekruter nie może zrekrutować samego siebie!')
@ -46,13 +51,12 @@ class Programmer(Recruiter):
Recruiter.id = recruiter Recruiter.id = recruiter
def recruited_by_who(self): def recruited_by_who(self):
print (f'Programista {self.name} {self.surname} zostal zrekrutowany przez rekrutera o nastepujacym id: {Recruiter.id}') print (f'Programista {self.name} {self.surname} zostal zrekrutowany przez rekrutera o nastepujacym id: {Recruiter.id}')
print('-------------------------')
pracownik1 = Employee('Stefan', 'Stefanski') pracownik1 = Employee('Stefan', 'Stefanski')
print(pracownik1.name) print(pracownik1.name)
print(pracownik1.surname) print(pracownik1.surname)
@ -67,9 +71,9 @@ pracownik3 =Recruiter('Kasia', 'Kasinska')
print(pracownik3.name) print(pracownik3.name)
print(pracownik3.surname) print(pracownik3.surname)
print(pracownik3.id) print(pracownik3.id)
print(pracownik3.recruit(5)) pracownik3.recruit(5)
print(pracownik3.recruit(0)) pracownik3.recruit(0)
print(pracownik3.recruit(1)) pracownik3.recruit(1)
print(pracownik3) print(pracownik3)
@ -78,10 +82,10 @@ print(pracownik4.name)
print(pracownik4.surname) print(pracownik4.surname)
print(pracownik4.id) print(pracownik4.id)
print(pracownik4.get_id()) print(pracownik4.get_id())
print(pracownik4.recruited_by_who()) pracownik4.recruited_by_who()
print('-------------------------') print('-------------------------')
print(pracownik1.id) print(Employee.id)
print(pracownik2.id)
print(pracownik3.id) print(Employee.lista_id)
print(pracownik4.id) print('-------------------------')