项目的具体源码,已经打包放在博客末尾

Java 项目:员工管理系统

搭建环境:

​ Idea 集成开发工具

技术点:

  • 数组
  • 面向对象
    • 继承
    • 多态
    • 接口
  • 异常的处理

项目结构:

image-20200803183234647

image-20200803183348955

代码示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
public class TeaView {
private NameLIstService lIstService = new NameLIstService();
private TeamService teamService = new TeamService();

public void enterMainMenu(){
boolean loopFlag = true;
char key = 0;
while(loopFlag){
if(! (key == '1')){
listAllEmployees();
}

System.out.print("1-团队列表 2-添加团队成员 3-删除团队成员 4-退出 请选择(1-4):");
key = TSUtility.readMenuSelection();
System.out.println();
switch (key){
case '1':
getTeam();
break;
case '2':
addMenber();
break;
case '3':
deleMember();
break;
case '4':
System.out.print("确认是否退出(Y/N):");
char yn = TSUtility.readConfirmSelection();
if(yn == 'Y'){
loopFlag = false;
break;
}
}
}
}

/**
* 以表格形式列出公司所有的员工
*/
public void listAllEmployees(){
System.out.println("\n--------------------开发团队调度软件---------------------\n");
Employee[] employees = lIstService.getAllEmployees();
if(employees.length == 0){
System.out.println("没有客户资料");
}else{
System.out.println("ID\t姓名\t\t年龄\t\t工资\t\t职位\t\t状态\t\t奖金\t\t股票\t\t领用设备");
}
for(Employee e : employees){
System.out.println(" "+ e);
}
System.out.println("-------------------------------------------------------------------------------");
}

/**
* 显示团队成员列表操作
*/
public void getTeam(){
System.out.println("\n--------------------团队成员列表---------------------\n");
Programmer[] team = teamService.getTeam();
if(team.length == 0){
System.out.println("开发团队目前没有成员!");
}else{
System.out.println("TID/ID\t姓名\t\t年龄\t\t工资\t\t职位\t\t奖金\t\t股票");
}

for(Programmer p : team){
System.out.println(" " + p.getDetailsForTeam());
}
System.out.println("-----------------------------------------------------");
}

/**
* 实现添加成员的操作
*/
public void addMenber() {
System.out.println("---------------------添加成员---------------------");
System.out.print("请输入要添加的员工ID: ");
int id = TSUtility.readInt();

try {
Employee e = lIstService.getEmployee(id);
teamService.addMenber(e);
System.out.println("添加成功");
} catch (TeamException e) {
System.out.println("添加失败,原因:" + e.getMessage());
}
// 按回车键继续
TSUtility.readReturn();
}

/**
* 实现删除成员操作
*/
public void deleMember(){
System.out.println("---------------------删除成员---------------------");
System.out.print("请输入要删除员工的TID:");
int id = TSUtility.readInt();
System.out.println("确认是否删除(Y/N):");
char yn = TSUtility.readConfirmSelection();
if(yn =='N'){
return;
}

try {
teamService.removeMember(id);
System.out.println("删除成功");
} catch (TeamException e) {
System.out.println("删除失败,原因:" + e.getMessage());
}
//按回车键继续
TSUtility.readReturn();
}

public static void main(String[] args){
TeaView teaView = new TeaView();
teaView.enterMainMenu();
}

}

提取码:kp6t