Poprawa task02 z labs04
This commit is contained in:
parent
e1c6d662fd
commit
2d6ac6ef66
@ -9,11 +9,11 @@
|
||||
|
||||
|
||||
class Employee:
|
||||
_id = 0
|
||||
id = 0
|
||||
|
||||
def __init__(self, name, surname):
|
||||
Employee._id += 1
|
||||
self.id = Employee._id
|
||||
Employee.id += 1
|
||||
self.id = Employee.id
|
||||
self.name = name
|
||||
self.surname = surname
|
||||
|
||||
@ -22,47 +22,18 @@ class Employee:
|
||||
|
||||
|
||||
class Recruiter(Employee):
|
||||
recruited = []
|
||||
def __init__(self, name, surname):
|
||||
super().__init__(name, surname)
|
||||
self.recruited = []
|
||||
|
||||
def recruit(self, Employee):
|
||||
emp_id = Employee.id
|
||||
self.recruited.append(emp_id)
|
||||
def recruit(self, Employee_obj):
|
||||
self.recruited.append(Employee_obj.id)
|
||||
|
||||
|
||||
class Programmer(Employee):
|
||||
def __init__(self, name, surname, Recruiter):
|
||||
def __init__(self, name, surname, Recruiter_obj):
|
||||
super().__init__(name, surname)
|
||||
self.recruiter = Recruiter.id
|
||||
|
||||
|
||||
# setup new employees
|
||||
emp_1 = Employee('Janusz', 'Kowalski')
|
||||
emp_2 = Employee('Marek', 'Marecki')
|
||||
|
||||
print (emp_1.get_id())
|
||||
print (emp_2.get_id())
|
||||
|
||||
# setup new recruiter
|
||||
rec_1 = Recruiter('Random', 'Recruiter')
|
||||
rec_1.recruit(emp_2)
|
||||
|
||||
# check for Recruiter
|
||||
print(rec_1.id, rec_1.name, rec_1.surname, rec_1.recruited)
|
||||
|
||||
# setup new Programmer
|
||||
prog_1 = Programmer('Python', 'Programmer', rec_1)
|
||||
|
||||
# check for new programmer
|
||||
print(prog_1.id, prog_1.name, prog_1.surname, prog_1.recruiter)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
self.recruiter = Recruiter_obj.id
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user