人事管理系统设计思路
时间: 2023-10-14 09:08:04 浏览: 84
人事管理系统设计
人事管理系统设计思路:
1. 定义员工类Employee,包含员工编号、姓名、性别、年龄、职位、部门、入职时间等属性,以及相应的get/set方法。
2. 定义部门类Department,包含部门编号、部门名称、部门经理等属性,以及相应的get/set方法。
3. 定义职位类Position,包含职位编号、职位名称、职位描述等属性,以及相应的get/set方法。
4. 定义员工管理类EmployeeManager,包含添加员工、删除员工、修改员工信息、查询员工信息等方法。
5. 定义部门管理类DepartmentManager,包含添加部门、删除部门、修改部门信息、查询部门信息等方法。
6. 定义职位管理类PositionManager,包含添加职位、删除职位、修改职位信息、查询职位信息等方法。
7. 定义主函数类Main,实现人事管理系统的整体流程。
Java 代码如下:
1. Employee类
```
public class Employee {
private int id; // 员工编号
private String name; // 姓名
private String gender; // 性别
private int age; // 年龄
private String position; // 职位
private String department; // 部门
private String hireDate; // 入职时间
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getHireDate() {
return hireDate;
}
public void setHireDate(String hireDate) {
this.hireDate = hireDate;
}
}
```
2. Department类
```
public class Department {
private int id; // 部门编号
private String name; // 部门名称
private String manager; // 部门经理
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
}
```
3. Position类
```
public class Position {
private int id; // 职位编号
private String name; // 职位名称
private String description; // 职位描述
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
```
4. EmployeeManager类
```
import java.util.ArrayList;
import java.util.List;
public class EmployeeManager {
private List<Employee> employees = new ArrayList<>();
// 添加员工
public void addEmployee(Employee employee) {
employees.add(employee);
}
// 删除员工
public void deleteEmployee(int id) {
for (Employee employee : employees) {
if (employee.getId() == id) {
employees.remove(employee);
break;
}
}
}
// 修改员工信息
public void updateEmployee(Employee employee) {
for (Employee e : employees) {
if (e.getId() == employee.getId()) {
e.setName(employee.getName());
e.setGender(employee.getGender());
e.setAge(employee.getAge());
e.setPosition(employee.getPosition());
e.setDepartment(employee.getDepartment());
e.setHireDate(employee.getHireDate());
break;
}
}
}
// 查询员工信息
public Employee getEmployee(int id) {
for (Employee employee : employees) {
if (employee.getId() == id) {
return employee;
}
}
return null;
}
}
```
5. DepartmentManager类
```
import java.util.ArrayList;
import java.util.List;
public class DepartmentManager {
private List<Department> departments = new ArrayList<>();
// 添加部门
public void addDepartment(Department department) {
departments.add(department);
}
// 删除部门
public void deleteDepartment(int id) {
for (Department department : departments) {
if (department.getId() == id) {
departments.remove(department);
break;
}
}
}
// 修改部门信息
public void updateDepartment(Department department) {
for (Department d : departments) {
if (d.getId() == department.getId()) {
d.setName(department.getName());
d.setManager(department.getManager());
break;
}
}
}
// 查询部门信息
public Department getDepartment(int id) {
for (Department department : departments) {
if (department.getId() == id) {
return department;
}
}
return null;
}
}
```
6. PositionManager类
```
import java.util.ArrayList;
import java.util.List;
public class PositionManager {
private List<Position> positions = new ArrayList<>();
// 添加职位
public void addPosition(Position position) {
positions.add(position);
}
// 删除职位
public void deletePosition(int id) {
for (Position position : positions) {
if (position.getId() == id) {
positions.remove(position);
break;
}
}
}
// 修改职位信息
public void updatePosition(Position position) {
for (Position p : positions) {
if (p.getId() == position.getId()) {
p.setName(position.getName());
p.setDescription(position.getDescription());
break;
}
}
}
// 查询职位信息
public Position getPosition(int id) {
for (Position position : positions) {
if (position.getId() == id) {
return position;
}
}
return null;
}
}
```
7. Main类
```
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
EmployeeManager employeeManager = new EmployeeManager();
DepartmentManager departmentManager = new DepartmentManager();
PositionManager positionManager = new PositionManager();
while (true) {
System.out.println("请选择操作:");
System.out.println("1. 添加员工");
System.out.println("2. 删除员工");
System.out.println("3. 修改员工信息");
System.out.println("4. 查询员工信息");
System.out.println("5. 添加部门");
System.out.println("6. 删除部门");
System.out.println("7. 修改部门信息");
System.out.println("8. 查询部门信息");
System.out.println("9. 添加职位");
System.out.println("10. 删除职位");
System.out.println("11. 修改职位信息");
System.out.println("12. 查询职位信息");
System.out.println("0. 退出");
int choice = scanner.nextInt();
switch (choice) {
case 1:
Employee employee = new Employee();
System.out.print("请输入员工编号:");
employee.setId(scanner.nextInt());
System.out.print("请输入员工姓名:");
employee.setName(scanner.next());
System.out.print("请输入员工性别:");
employee.setGender(scanner.next());
System.out.print("请输入员工年龄:");
employee.setAge(scanner.nextInt());
System.out.print("请输入员工职位:");
employee.setPosition(scanner.next());
System.out.print("请输入员工部门:");
employee.setDepartment(scanner.next());
System.out.print("请输入员工入职时间:");
employee.setHireDate(scanner.next());
employeeManager.addEmployee(employee);
System.out.println("添加成功!");
break;
case 2:
System.out.print("请输入员工编号:");
int id = scanner.nextInt();
employeeManager.deleteEmployee(id);
System.out.println("删除成功!");
break;
case 3:
Employee e = new Employee();
System.out.print("请输入员工编号:");
e.setId(scanner.nextInt());
System.out.print("请输入员工姓名:");
e.setName(scanner.next());
System.out.print("请输入员工性别:");
e.setGender(scanner.next());
System.out.print("请输入员工年龄:");
e.setAge(scanner.nextInt());
System.out.print("请输入员工职位:");
e.setPosition(scanner.next());
System.out.print("请输入员工部门:");
e.setDepartment(scanner.next());
System.out.print("请输入员工入职时间:");
e.setHireDate(scanner.next());
employeeManager.updateEmployee(e);
System.out.println("修改成功!");
break;
case 4:
System.out.print("请输入员工编号:");
int id1 = scanner.nextInt();
Employee employee1 = employeeManager.getEmployee(id1);
if (employee1 != null) {
System.out.println("员工编号:" + employee1.getId());
System.out.println("员工姓名:" + employee1.getName());
System.out.println("员工性别:" + employee1.getGender());
System.out.println("员工年龄:" + employee1.getAge());
System.out.println("员工职位:" + employee1.getPosition());
System.out.println("员工部门:" + employee1.getDepartment());
System.out.println("员工入职时间:" + employee1.getHireDate());
} else {
System.out.println("该员工不存在!");
}
break;
case 5:
Department department = new Department();
System.out.print("请输入部门编号:");
department.setId(scanner.nextInt());
System.out.print("请输入部门名称:");
department.setName(scanner.next());
System.out.print("请输入部门经理:");
department.setManager(scanner.next());
departmentManager.addDepartment(department);
System.out.println("添加成功!");
break;
case 6:
System.out.print("请输入部门编号:");
int id2 = scanner.nextInt();
departmentManager.deleteDepartment(id2);
System.out.println("删除成功!");
break;
case 7:
Department d = new Department();
System.out.print("请输入部门编号:");
d.setId(scanner.nextInt());
System.out.print("请输入部门名称:");
d.setName(scanner.next());
System.out.print("请输入部门经理:");
d.setManager(scanner.next());
departmentManager.updateDepartment(d);
System.out.println("修改成功!");
break;
case 8:
System.out.print("请输入部门编号:");
int id3 = scanner.nextInt();
Department department1 = departmentManager.getDepartment(id3);
if (department1 != null) {
System.out.println("部门编号:" + department1.getId());
System.out.println("部门名称:" + department1.getName());
System.out.println("部门经理:" + department1.getManager());
} else {
System.out.println("该部门不存在!");
}
break;
case 9:
Position position = new Position();
System.out.print("请输入职位编号:");
position.setId(scanner.nextInt());
System.out.print("请输入职位名称:");
position.setName(scanner.next());
System.out.print("请输入职位描述:");
position.setDescription(scanner.next());
positionManager.addPosition(position);
System.out.println("添加成功!");
break;
case 10:
System.out.print("请输入职位编号:");
int id4 = scanner.nextInt();
positionManager.deletePosition(id4);
System.out.println("删除成功!");
break;
case 11:
Position p = new Position();
System.out.print("请输入职位编号:");
p.setId(scanner.nextInt());
System.out.print("请输入职位名称:");
p.setName(scanner.next());
System.out.print("请输入职位描述:");
p.setDescription(scanner.next());
positionManager.updatePosition(p);
System.out.println("修改成功!");
break;
case 12:
System.out.print("请输入职位编号:");
int id5 = scanner.nextInt();
Position position1 = positionManager.getPosition(id5);
if (position1 != null) {
System.out.println("职位编号:" + position1.getId());
System.out.println("职位名称:" + position1.getName());
System.out.println("职位描述:" + position1.getDescription());
} else {
System.out.println("该职位不存在!");
}
break;
case 0:
System.exit(0);
default:
System.out.println("输入有误,请重新输入!");
}
}
}
}
```
阅读全文