forked from tdwojak/Python2017
Poprawa task02 z labs04
This commit is contained in:
parent
e1c6d662fd
commit
2d6ac6ef66
@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
|
|
||||||
class Employee:
|
class Employee:
|
||||||
_id = 0
|
id = 0
|
||||||
|
|
||||||
def __init__(self, name, surname):
|
def __init__(self, name, surname):
|
||||||
Employee._id += 1
|
Employee.id += 1
|
||||||
self.id = Employee._id
|
self.id = Employee.id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.surname = surname
|
self.surname = surname
|
||||||
|
|
||||||
@ -22,47 +22,18 @@ class Employee:
|
|||||||
|
|
||||||
|
|
||||||
class Recruiter(Employee):
|
class Recruiter(Employee):
|
||||||
recruited = []
|
def __init__(self, name, surname):
|
||||||
|
super().__init__(name, surname)
|
||||||
|
self.recruited = []
|
||||||
|
|
||||||
def recruit(self, Employee):
|
def recruit(self, Employee_obj):
|
||||||
emp_id = Employee.id
|
self.recruited.append(Employee_obj.id)
|
||||||
self.recruited.append(emp_id)
|
|
||||||
|
|
||||||
|
|
||||||
class Programmer(Employee):
|
class Programmer(Employee):
|
||||||
def __init__(self, name, surname, Recruiter):
|
def __init__(self, name, surname, Recruiter_obj):
|
||||||
super().__init__(name, surname)
|
super().__init__(name, surname)
|
||||||
self.recruiter = Recruiter.id
|
self.recruiter = Recruiter_obj.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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user