#!/usr/bin/env python2 # -*- coding: utf-8 -*- #**ćwiczenie 2** #Napisz prostą hierarchię klas: # * Klasa bazowa ``Employee``, która będzie zawierać informacje o imieniu i nazwisku pracownika. Ponadto każdy pracownik otrzyma numer ``id``, który będzie unikatowy. Wykorzystaj do tego atrybut statyczny. Napisz metodę ``get_id``, która zwraca identyfikator pracownika. # * Klasy pochodna: ``Recruiter``, która ma dodatkową mtodę ``recruit``, która jako parament przyjmuje obiekt ``Employee`` i zapisuje jego ``id`` w liście ``self.recruited``. # * Klasa pochodna ``Programmer``. Klasa ``Programmer`` ma przyjąć w konstruktorze podstawowe informacje (imię i nazwisko) oraz obiekt rekturera. Ponadto stwórz atrybut ``recruiter``, który będzie przechowywać ``id`` rekrutera. class Employee(): id=0 def __init__(self, firstname, surname): self.id = Employee.id self.firstname = firstname self.surname = surname Employee.id = Employee.id + 1 def get_id(self): return self.id class Recruiter(Employee): def __init__(self,firstname,surname): super().__init__(firstname,surname) self.recruited=[] def recruite(self,Employee): self.recruited.append(Employee.get_id()) class Programmer(Employee): def __init__(self,firstname,surname,Recruiter): super().__init__(firstname,surname) self.recruiter = Recruiter.get_id() E1 = Employee('Karol', 'Kapusta') E2 = Employee('Jola', 'Kalafior') print('Employee1', E1.firstname, E1.surname) print('Employee2', E2.firstname, E2.surname) R = Recruiter('John','Szef') print('Recruiter',R.firstname, R.surname) P = Programmer('Ali','Baba', R) print('Programmer',P.firstname, P.surname) R.recruite(E1) print(R.recruited)