员工管理系统java版

2025-05-29 0 48

员工管理系统要求如下:

通过面向对象的编程思想,实现员工信息的增删改查,存储结构为数组。限定数组长度为100。

实现页面:

员工管理系统java版

添加员工

员工管理系统java版

查找员工

员工管理系统java版

修改员工

员工管理系统java版

删除员工、退出

工程目录结构:

员工管理系统java版

1.employee基类

?

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
/**

* @author 李广亮

*

*/

public class employee {

/**

* 成员属性:id、姓名、职务、请假天数、基本工资

*/

private string id;

private string name;

private string job;

private int holiday;

private double salary;

/**

* 计算工资

*/

public double sunsalary(double salary, int holiday) {

return salary - (salary/30) * holiday;

}

/**

* get和set方法

*/

public string getid() {

return id;

}

public void setid(string id) {

id = id;

}

public string getname() {

return name;

}

public void setname(string name) {

this.name = name;

}

public string getjob() {

return job;

}

public void setjob(string job) {

this.job = job;

}

public int getholiday() {

return holiday;

}

public void setholiday(int holiday) {

this.holiday = holiday;

}

public double getsalary() {

return salary;

}

public void setsalary(double salary) {

this.salary = salary;

}

/**

* tostring()方法

*/

public string tostring() {

return "编号:" + id + ", 姓名:" + name + ", 职务" + job

+ ", 请假天数:" + holiday + ", 工资:" + salary;

}

}

2.普通员工类commonemployee

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15
public class commonemployee extends employee {

/**

* 普通员工工资

* 在基本工资的基础上增加10%的工作餐,50%的岗位补助,200元住房补助

* @param 工资

* @param 请假天数

*/

@override

public double sunsalary(double salary, int holiday) {

double sum = salary + salary*0.1 + salary*0.5 + 200;

return sum - sum/30 * holiday;

}

}

3.经理manageremployee

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15
public class manageremployee extends employee {

/**

* 经理工资

* 在基本工资的基础上增加20%的工作餐,50%的岗位补助,500元住房补助

* @param 工资

* @param 请假天数

*/

@override

public double sunsalary(double salary, int holiday) {

double sum = salary + salary*0.2 + salary*0.5 + 500;

return sum - sum/30 * holiday;

}

}

4.懂事directoremployee

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15
public class manageremployee extends employee {

/**

* 经理工资

* 在基本工资的基础上增加20%的工作餐,50%的岗位补助,500元住房补助

* @param 工资

* @param 请假天数

*/

@override

public double sunsalary(double salary, int holiday) {

double sum = salary + salary*0.2 + salary*0.5 + 500;

return sum - sum/30 * holiday;

}

}

5.业务逻辑类testemd

?

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

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201
/**

* @author 李广亮

*

*/

public class testemd {

/**

* len代表数组的当前下标

*/

static int len = -1;

static employee[] emp = new employee[100];

static scanner sc = new scanner(system.in);

/**

* 增加新雇员

*/

public void addemployee() {

employee em = null;

system.out.println("---增加员工---");

system.out.print("请输入员工编号:");

string id = sc.next();

system.out.print("请输入员工姓名:");

string name = sc.next();

system.out.print("请输入员工职务(员工、经理、懂事):");

string job = sc.next();

system.out.print("请输入员工请假天数:");

int holiday = sc.nextint();

system.out.print("请输入员工基本工资:");

double salary = sc.nextdouble();

//在此作一下逻辑判断,根据job的不同,创建不同的employee子类

if(job.equals("员工")) {

em = new commonemployee();

} else if(job.equals("经理")) {

em = new manageremployee();

} else if(job.equals("懂事")) {

em = new directoremployee();

} else {

system.out.println("输入不正确!");

}

em.setid(id);

em.setname(name);

em.setjob(job);

em.setholiday(holiday);

em.setsalary(salary);

//len先加1后使用,变为emp[0]

emp[++len] = em;

printemployee(emp[len]);

system.out.println("添加成功!");

}

/**

* 删除员工

*/

public void deleteemployee() {

system.out.println("------删除员工------");

system.out.println("---请输入员工姓名:---");

//设置一个boolean类型的flg标志,若查找不到则为false

boolean flg = false;

string name = sc.next();

for(int i=0; i<=len; i++) {

//若查找成功,则把emp[i]数组后面的指针往前移一位,覆盖掉当前的指向对象

if(emp[i].getname().equals(name)) {

printemployee(emp[i]);

for(int j=i; j<=len; j++) {

emp[j] = emp[j+1];

}

//前移后,最后一位置空,len--

emp[len] = null;

len--;

system.out.println("删除成功!");

flg = true;

break;

}

}

if(!flg) {

system.out.println("查无此人,请重新输入:");

deleteemployee();

}

}

/**

* 修改雇员信息

* @param args

* @return

*/

public void updateemployee() {

system.out.println("------修改员工------");

system.out.println("---请输入员工姓名:---");

//设置一个boolean类型的flg标志,若查找不到则为false

boolean flg = false;

string name = sc.next();

for(int i=0; i<=len; i++) {

if(emp[i].getname().equals(name)) {

printemployee(emp[i]);

system.out.println("---请按照提示输入修改信息---");

system.out.print("请输入员工编号:");

emp[i].setid(sc.next());

system.out.print("请输入员工姓名:");

emp[i].setname(sc.next());

system.out.print("请输入员工职务(员工、经理、懂事):");

emp[i].setjob(sc.next());

system.out.print("请输入员工请假天数:");

emp[i].setholiday(sc.nextint());

system.out.print("请输入员工基本工资:");

emp[i].setsalary(sc.nextdouble());

//修改完成后打印一下

printemployee(emp[i]);

system.out.println("修改成功!");

flg = true;

break;

}

}

if(!flg) {

system.out.println("查无此人,请重新输入:");

updateemployee();

}

}

/**

* 根据姓名查找雇员信息

* @param args

*/

public void findemployee() {

system.out.println("------查找员工------");

system.out.println("---请输入员工姓名:---");

//设置一个boolean类型的flg标志,若查找不到则为false

boolean flg = false;

string name = sc.next();

for( int i=0; i<=len; i++) {

if(emp[i].getname().equals(name)) {

printemployee(emp[i]);

system.out.println("查找成功!");

flg = true;

break;

}

}

if(!flg) {

system.out.println("查无此人,请重新输入:");

findemployee();

}

}

/**

* 打印雇员信息

* @param args

*/

public void printemployee(employee em) {

system.out.print(" 编号: " + em.getid());

system.out.print(" 姓名: " + em.getname());

system.out.print(" 职务: " + em.getjob());

system.out.print(" 请假天数 : " + em.getholiday());

//参数:1.基本工资 2.请假天数

double sum = em.sunsalary(em.getsalary(), em.getholiday());

system.out.println(" 工资:" + sum);

}

public static void main(string[] args) {

testemd te = new testemd();

//开始界面

system.out.println("|----------------|");

system.out.println("|-----1. 增加 -----|");

system.out.println("|-----2. 删除 -----|");

system.out.println("|-----3. 修改 -----|");

system.out.println("|-----4. 查询 -----|");

system.out.println("|-----0. 退出 -----|");

system.out.println("|----------------|");

//业务选择

label : while(true) {

system.out.println("请选择业务:");

int select = sc.nextint();

switch (select) {

case 1: //添加新雇员

te.addemployee();

break;

case 2: //删除雇员

te.deleteemployee();

break;

case 3: //修改雇员信息

te.updateemployee();

break;

case 4: //根据姓名查找雇员信息

te.findemployee();

break;

case 0: //退出

system.out.println("退出成功!");

break label;

default:

system.out.println("您输入的数字不正确!");

break;

}

}

}

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。

原文链接:http://blog.csdn.net/liguangliang_bzu/article/details/48198339

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 员工管理系统java版 https://www.kuaiidc.com/114188.html

相关文章

发表评论
暂无评论