Class EmployeeManagementSystem: PDF
Class EmployeeManagementSystem: PDF
def __init__(self):
self.employees = {} # Dictionary to store employee details
self.department_wise_employees = {} # Dictionary to store department-wise employees
self.employee_stack = [] # Stack to add multiple employees
self.employee_queue = [] # Queue to manage employees who are leaving
def sort_employees_by_salary(self):
sorted_employees = sorted(self.employees.items(), key=lambda x: x[1]["salary"],
reverse=True)
return sorted_employees
def remove_duplicate_employees(self, employee_list):
unique_employees = set()
for employee in employee_list:
unique_employees.add(tuple(employee.items()))
return unique_employees
def display_employee_stack(self):
return self.employee_stack[::-1]
def display_employee_queue(self):
return self.employee_queue
def main():
ems = EmployeeManagementSystem()
while True:
print("\nEmployee Management System\n")
print("1. Add New Employee")
print("2. Search Employee by ID")
print("3. Sort Employees by Salary")
print("4. Remove Duplicate Employees")
print("5. Department-wise Employee Details")
print("6. Add Multiple Employees using Stack")
print("7. Display Employee Stack")
print("8. Add Employee to Queue")
print("9. Display Employee Queue")
print("10. Exit")
if choice == "1":
id = input("Enter employee ID: ")
name = input("Enter employee name: ")
age = input("Enter employee age: ")
department = input("Enter employee department: ")
salary = float(input("Enter employee salary: "))
ems.add_employee(id, name, age, department, salary)
elif choice == "2":
id = input("Enter employee ID: ")
print(ems.search_employee(id))
elif choice == "3":
print(ems.sort_employees_by_salary())
elif choice == "4":
employee_list = [
{"id": "1", "name": "John", "age": 30, "department": "HR", "salary": 50000.0},
{"id": "2", "name": "Jane", "age": 25, "department": "Marketing", "salary": 60000.0},
{"id": "1", "name": "John", "age": 30, "department": "HR", "salary": 50000.0},
]
print(ems.remove_duplicate_employees(employee_list))
elif choice == "5":
print(ems.department_wise_employees)
elif choice == "6":
employees = [
{"id": "3", "name": "Bob", "age": 35, "department": "IT", "salary": 70000.0},
{"id": "4", "name": "Alice", "age": 28, "department": "Finance", "salary": 55000.0},
]
ems.add_multiple_employees(employees)
elif choice == "7":
print(ems.display_employee_stack())
elif choice == "8":
id = input("Enter employee ID: ")
ems.add_employee_to_queue(id)
ems.add_employee_to_queue(id)
elif choice == "9":
print(ems.display_employee_queue())
elif choice == "10":
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()