项目的具体源码,已经打包放在博客末尾
Java 项目:员工管理系统
搭建环境:
Idea 集成开发工具
技术点:
- 数组
- 面向对象
- 继承
- 多态
- 接口
- 异常的处理
项目结构:
代码示例:
代码语言:javascript复制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("IDt姓名tt年龄tt工资tt职位tt状态tt奖金tt股票tt领用设备");
}
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/IDt姓名tt年龄tt工资tt职位tt奖金tt股票");
}
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
下载源码