From 2d6ac6ef66d8fbb4f61c339761f388f7ecd98a77 Mon Sep 17 00:00:00 2001 From: s45156 Date: Wed, 24 Jan 2018 12:06:54 +0100 Subject: [PATCH] Poprawa task02 z labs04 --- labs04/task02.py | 49 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/labs04/task02.py b/labs04/task02.py index 6e30dfa..ebd505f 100644 --- a/labs04/task02.py +++ b/labs04/task02.py @@ -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