设计一个计算机程序,能够实现简单的员工管理功能。 【任务要求】 (1)每个员工的信息包括:编号、姓名、性别、出生年月、学历、职务、电话、住址等。
时间: 2023-11-08 07:47:19 浏览: 89
好的,我可以帮您设计一个简单的员工管理程序,包含以下功能:
1. 添加员工信息:输入员工的编号、姓名、性别、出生年月、学历、职务、电话、住址等信息,将其保存到程序中。
2. 查询员工信息:根据员工编号或姓名查询员工信息,并将其展示出来。
3. 修改员工信息:根据员工编号或姓名修改员工信息。
4. 删除员工信息:根据员工编号或姓名删除员工信息。
以下是程序的伪代码:
```
class Employee:
def __init__(self, id, name, gender, birthdate, education, position, phone, address):
self.id = id
self.name = name
self.gender = gender
self.birthdate = birthdate
self.education = education
self.position = position
self.phone = phone
self.address = address
class EmployeeManagement:
def __init__(self):
self.employee_list = []
def add_employee(self, employee):
self.employee_list.append(employee)
def search_employee(self, keyword):
result = []
for employee in self.employee_list:
if keyword in employee.id or keyword in employee.name:
result.append(employee)
return result
def update_employee(self, keyword, new_employee):
for index, employee in enumerate(self.employee_list):
if keyword in employee.id or keyword in employee.name:
self.employee_list[index] = new_employee
def delete_employee(self, keyword):
for index, employee in enumerate(self.employee_list):
if keyword in employee.id or keyword in employee.name:
del self.employee_list[index]
# 示例
management = EmployeeManagement()
# 添加员工
employee1 = Employee("001", "张三", "男", "1990-01-01", "本科", "经理", "13800000001", "上海市浦东新区")
management.add_employee(employee1)
employee2 = Employee("002", "李四", "女", "1995-01-01", "硕士", "工程师", "13800000002", "上海市徐汇区")
management.add_employee(employee2)
# 查询员工
result = management.search_employee("张")
for employee in result:
print(employee.name, employee.phone)
# 修改员工
new_employee = Employee("001", "王五", "男", "1990-01-01", "本科", "总监", "13800000003", "上海市闵行区")
management.update_employee("张三", new_employee)
# 删除员工
management.delete_employee("李四")
```
阅读全文