Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Employee:
- def __init__(self, i_num, fname, lname, work_experience, education_level, salary, age):
- self.i_num = i_num
- self.fname = fname
- self.lname = lname
- self.work_experience = work_experience
- self.education_level = education_level
- self.salary = salary
- self.age = age
- def display_info(self):
- print(f"Служебен номер: {self.i_num}")
- print(f"Име: {self.fname}")
- print(f"Фамилия: {self.lname}")
- print(f"Трудов стаж: {self.work_experience} години")
- print(f"Образование: {self.education_level}")
- print(f"Заплата: {self.salary} BGN")
- print(f"Възраст: {self.age} години")
- def bonus(self):
- bonus_percent = 0
- if self.education_level == "висше":
- bonus_percent += 5
- if self.education_level == "средно":
- bonus_percent += 2
- bonus_percent += 1.2 * self.work_experience
- return self.salary * (bonus_percent / 100)
- def sort_employee(employee_list):
- sorted_employees = sorted(employee_list, key=lambda x: x.age)
- for employee in sorted_employees:
- employee.display_info()
- def search_by_name(employee_list, name, lname):
- found = False
- for employee in employee_list:
- if employee.fname == name and employee.lname == lname:
- employee.display_info()
- found = True
- break
- if not found:
- print("Not found!!!")
- def print_by_education_experience(employee_list, education, experience):
- for employee in employee_list:
- if employee.education_level == education and employee.work_experience == experience:
- employee.display_info()
- def remove_employee(employee_list, i_num):
- for employee in employee_list:
- if employee.i_num == i_num:
- employee_list.remove(employee)
- print("Information deleted !!!")
- break
- else:
- print("Wrong i_num !!!")
- employee_list = []
- n = int(input("Въведете брой служители: "))
- for _ in range(n):
- i_num = input("Служебен номер: ")
- fname = input("Име: ")
- Iname = input("Фамилия: ")
- work_experience = int(input("Трудов стаж (години): "))
- education_level = input("Образование (основно, средно, висше): ")
- salary = float(input("Заплата: "))
- age = int(input("Възраст: "))
- employee = Employee(i_num, fname, Iname, work_experience, education_level, salary, age)
- employee_list.append(employee)
- while True:
- print("\nМеню:")
- print("1. Сортиране на служителите по възраст")
- print("2. Търсене на служител по име и фамилия")
- print("3. Извеждане на служители по образование и стаж")
- print("4. Изтриване на служител по служебен номер")
- print("5. Изход")
- choice = int(input("Изберете опция: "))
- match choice:
- case 1:
- sort_employee(employee_list)
- case 2:
- name = input("Въведете име: ")
- Iname = input("Въведете фамилия: ")
- search_by_name(employee_list, name, Iname)
- case 3:
- education = input("Въведете образование: ")
- experience = int(input("Въведете стаж (години): "))
- print_by_education_experience(employee_list, education, experience)
- case 4:
- i_num = input("Въведете служебен номер: ")
- remove_employee(employee_list, i_num)
- print(employee_list)
- case 5:
- break
- case _:
- print("Невалиден избор. Моля, опитайте отново.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement