Advertisement
Radoslav_03

2_zad_sam.py

Sep 17th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.11 KB | None | 0 0
  1. class Employee:
  2.     def __init__(self, i_num, fname, lname, work_experience, education_level, salary, age):
  3.         self.i_num = i_num
  4.         self.fname = fname
  5.         self.lname = lname
  6.         self.work_experience = work_experience
  7.         self.education_level = education_level
  8.         self.salary = salary
  9.         self.age = age
  10.  
  11.     def display_info(self):
  12.         print(f"Служебен номер: {self.i_num}")
  13.         print(f"Име: {self.fname}")
  14.         print(f"Фамилия: {self.lname}")
  15.         print(f"Трудов стаж: {self.work_experience}")
  16.         print(f"Образование: {self.education_level}")
  17.         print(f"Заплата: {self.salary}")
  18.         print(f"Възраст: {self.age}")
  19.  
  20.     def bonus(self):
  21.         bonus = 0
  22.         if self.education_level == "Висше":
  23.             bonus += 5
  24.         elif self.education_level == "Средно":
  25.             bonus += 2
  26.  
  27.         bonus += 1.2 * self.work_experience
  28.         return self.salary * (bonus / 100)
  29.  
  30. def sort_employee(employee_list):
  31.     sorted_employees = sorted(employee_list, key=lambda x: x.age)
  32.     for employee in sorted_employees:
  33.         employee.display_info()
  34.  
  35. def search_by_name(employee_list, name, lname):
  36.     found = False
  37.     for employee in employee_list:
  38.         if employee.fname == name and employee.lname == lname:
  39.             employee.display_info()
  40.             found = True
  41.             break
  42.  
  43.     if not found:
  44.         print("Not found!!!")
  45.  
  46. def print_by_education_experience(employee_list, education, experience):
  47.     for employee in employee_list:
  48.         if employee.education_level == education and employee.work_experience == experience:
  49.             employee.display_info()
  50.  
  51. def remove_employee(employee_list, i_num):
  52.     for employee in employee_list:
  53.         if employee.i_num == i_num:
  54.             employee_list.remove(employee)
  55.             print("Information deleted!!!")
  56.             break
  57.     else:
  58.         print("Wrong i_num!!!")
  59.  
  60. n = int(input("Въведете броят на служителите: "))
  61.  
  62. employee_list = []
  63.  
  64. for _ in range(n):
  65.     i_num = int(input())
  66.     fname = input()
  67.     lname = input()
  68.     work_experience = int(input())
  69.     education_level = input()
  70.     salary = int(input())
  71.     age = int(input())
  72.  
  73.     employee = Employee(i_num, fname, lname, work_experience, education_level, salary, age)
  74.     employee_list.append(employee)
  75.  
  76. while True:
  77.  
  78.     choice = int(input("Изберете опция от 1 до 5: "))
  79.    
  80.     match choice:
  81.  
  82.         case 1:
  83.             sort_employee(employee_list)
  84.         case 2:
  85.             name = input()
  86.             lname = input()
  87.             search_by_name(employee_list, name, lname)
  88.         case 3:
  89.             education = input()
  90.             experience = int(input())
  91.             print_by_education_experience(employee_list, education, experience)
  92.         case 4:
  93.             i_num = int(input())
  94.             remove_employee(employee_list, i_num)
  95.             print(employee_list)
  96.         case 5:
  97.             break
  98.         case _:
  99.             print("Няма такава опция!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement