class Employee:
    nazwy_kolumn = ('employee_id', 'first_name', 'last_name', 'job_title', 'salary', 'hire_date',
                 'department_name', 'address', 'postal_code', 'city', 'country')

    SEP = ';'

    def __init__(self, employee_id, first_name, last_name, job_title, salary, hire_date, department_name, address, postal_code, city, country):
        self.employee_id = int(employee_id)
        self.first_name = first_name
        self.last_name = last_name
        self.job_title = job_title
        self.salary = int(salary)
        self.hire_date = hire_date
        self.department_name = department_name
        self.address = address
        self.postal_code = postal_code
        self.city = city
        self.country = country


    def __str__(self):
        return f'Pracownik nr {self.employee_id}: {self.first_name} {self.last_name} ({self.job_title}), pensja {self.salary}'


    # Tutaj wczytywanie danych z pliku zrobimy jako metodę statyczną wewnątrz klasy.
    # Metoda statyczna nie przyjmuje parametru self i jest wywoływana nie na obiekcie, tylko na klasie.
    @staticmethod
    def read_csv(file_path='emps.csv'):
        with open(file_path, mode='r', encoding='utf-8') as file:
            file.readline()
            return [Employee(*(line.strip().split(Employee.SEP))) for line in file]


    @staticmethod
    def write_csv(emps, sciezka):
        with open(sciezka, mode='w', encoding='utf-8') as file:
            print(*Employee.nazwy_kolumn, sep=Employee.SEP, file=file)
            for emp in emps:
                print(*emp.__dict__.values(), sep=Employee.SEP, file=file)
