您的位置:首页 > 汽车 > 时评 > java——项目开发团队分配管理软件

java——项目开发团队分配管理软件

2024/9/19 3:38:49 来源:https://blog.csdn.net/2301_80114420/article/details/141885152  浏览:    关键词:java——项目开发团队分配管理软件

一、系统功能结构

二、项目结构:

三、项目实现:

1、用户注册和登录模块:
package com.team.view;import java.util.Random;
import java.util.Scanner;public class LoginView {//首先给定属性:登录用户和密码private String userName = "";private String password = "";//注册功能public void regist() throws InterruptedException {TSUtility.loadSpecialEffects();System.out.println("开始注册:");Scanner sc = new Scanner(System.in);System.out.println("请输入你的注册账户名称:");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("请输入你的注册密码:");String password = TSUtility.readKeyBoard(8, false);this.password = password;System.out.println("注册成功!请登录!");}//登录功能public void login() throws InterruptedException {//登录失败的次数限制int count = 5;boolean flag = true;while (flag) {System.out.println("********************🐱");System.out.println("***   <登录界面>   ***");System.out.println("***     (:      ***🐱");System.out.println("********************🐱");System.out.println("请输入你的登录账户名称:");String userName = TSUtility.readKeyBoard(4, false);System.out.println("请输入你的登录密码:");String password = TSUtility.readKeyBoard(8, false);//未注册if (this.userName.length() == 0 || this.password.length() == 0) {System.out.println("未检测到您的账号,请您先注册!");regist();}//已注册//正常登录else if (this.userName.equals(userName) && this.password.equals(password)) {TSUtility.loadSpecialEffects();System.out.println("登陆成功!欢迎您:" + userName);flag = false;} else {if (count <= 0) {System.out.println("登录次数不足!退出!");return;} else {count--;System.out.println("登录失败!用户名或密码不匹配!");System.out.println("登录次数还剩" + count + "次,请重新输入:");}}}}//修改功能public void update() throws InterruptedException {boolean flag = true;while (flag) {System.out.println("********************🐱");System.out.println("***   <修改界面>   ***");System.out.println("***     (:      ***🐱");System.out.println("********************🐱");System.out.println("请输入你需要修改的类型:");System.out.println("1(修改用户名)");System.out.println("2(修改密码名)");System.out.println("3(修改用户名和密码名)");System.out.println("4(不修改,退出)");Scanner sc = new Scanner(System.in);String options = sc.next();if (options.equals("1")) {System.out.println("请输入你的修改的账户名称:");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("修改成功!");} else if (options.equals("2")) {System.out.println("请输入你的修改密码:");String password = TSUtility.readKeyBoard(8, false);this.password = password;System.out.println("修改成功!");} else if (options.equals("3")) {System.out.println("请输入你的修改的账户名称:");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("请输入你的修改密码:");String password = TSUtility.readKeyBoard(8, false);this.password = password;System.out.println("修改成功!");}else if (options.equals("4")) {System.out.println("退出中");TSUtility.loadSpecialEffects();flag = false;}else  {System.out.println("输入错误!请输入“1”或者“2”或者“3”或者“4”:");}}}}
2、开发团队调度管理模块:
 
/*
开发团队调度管理模块*/public class TeamView {private NameListService listSvc = new NameListService();private TeamService TeamSvc = new TeamService();TeamService t;  //团队服务操作对象//    团队管理主界面及控制方法public void TeamControl() {boolean teamFlag1 = true;char teamChoose1 = 0;do {System.out.print(ANSI_RESET + ANSI_YELLOW);     //格式化输出 字体颜色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("⬇    请选择:(1-5)  ");teamChoose1 = TSUtility.readMenuSelectionPro();switch (teamChoose1) {case '1':TeamSvc.teamList();    //查看团队
//                    this.enterMainMenu();break;case '2':TeamSvc.teamAdd();break;case '3':TeamSvc.teamDelete();break;case '4':this.enterMainMenu();  //进入团队成员管理break;case '5':System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {teamFlag1 = false;}break;default:System.out.println("输入有误!请重新输入!");break;}} while (teamFlag1);}/*团队成员管理主界面显示及控制方法*/public void enterMainMenu() {if (TeamSvc.teams.size() == 0){     //无团队无法进行成员管理System.out.println("当前没有团队信息,请先添加团队!");return;}TeamSvc.teamList();System.out.println("请输入你要进行操作的团队id:");int id = -1;do{id = TSUtility.readTeamId();if (id > TeamSvc.teams.size()){System.out.println("输入id大于当前团队数,请重新输入:");}else{break;}}while(true);int index = id-1;t = TeamSvc.teamServices.get(index);    //获取团队对象的操作对象boolean teamFlag2 = true;char teamChoose2 = 0;do {System.out.print(ANSI_RESET + ANSI_YELLOW);System.out.println("🔣   ~团队成员管理主菜单~   🔣");System.out.println("🐕   1. <查看团队成员>     *");System.out.println("🐖   2. <添加团队成员>     *");System.out.println("🐱   3. <删除团队成员>     *");System.out.println("🐂   4. <退出>           *");System.out.println("⬇    请选择:(1-4)  ");teamChoose2 = TSUtility.readMenuSelection();switch (teamChoose2) {case '1':this.getTeam();break;case '2':this.addMember();break;case '3':deleteMember();break;case '4':System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {teamFlag2 = false;}break;default:System.out.println("输入有误!请重新输入!");break;}}while (teamFlag2);}//    以表格形式列出公司所有成员private void listAllEmployees() throws InterruptedException {listSvc.showEmployee();}//    显示团队成员列表操作public void getTeam() {System.out.println("🐕-------------<团队成员列表>-------------🐕");try {Programmer[] team = t.getTeam();  //获取团队成员数组if (team.length == 0) {System.out.println("暂无团队成员,请先添加!");} else {System.out.println("TID/ID\t 姓名\t年龄\t 工资\t 职位\t 状态\t 奖金\t 股票\t 领用设备");for (Programmer teamNum : team) {  //遍历输出System.out.println(teamNum.getMemberId() + "/" + teamNum);}}} catch (Exception e) {e.printStackTrace();}}//    实现添加成员操作private void addMember() {try {listAllEmployees();    //显示员工列表} catch (InterruptedException e) {e.printStackTrace();}System.out.println("请输入要添加的员工id:");int id = TSUtility.readInt();try {Employee addEl = listSvc.getEmployee(id);    //获取id对象t.addMember(addEl);System.out.println("添加成功!");} catch (TeamException e) {System.out.println(e.getMessage() + "\n");} catch (NameListService.TeamException e) {e.printStackTrace();}}//    实现删除成员操作private void deleteMember() {try {Programmer[] team = t.getTeam();  //获取团队成员数组if (team.length==0){System.out.println("暂无团队成员,请先添加!");return;}System.out.println("TID/ID\t 姓名\t年龄\t 工资\t 职位\t 状态\t 奖金\t 股票\t 领用设备");for (Programmer teamNum : team) {  //遍历输出System.out.println(teamNum.getMemberId() + "/" + teamNum);}} catch (Exception e) {e.printStackTrace();}System.out.println("请输入需要删除的团队成员id:");int i = TSUtility.readInt();try {t.removeMember(i);System.out.println("删除成功!");} catch (TeamException e) {e.printStackTrace();}}
}
3、TeamService:
public class TeamService extends ArrayList<Programmer[]> {//用于自动生成团队成员的memberIdprivate static int counter = 1;//团队人数上限private final int MAX_MEMBER = 5;//保存当前团队成员private Programmer[] team = new Programmer[MAX_MEMBER];//团队实际人数private int total = 0;// 团队管理添加内容private static int teamCounter = 1; //团队idprivate static int teamTotal = 0; //实际团队数public static ArrayList<Team> teams = new ArrayList<Team>();    //团队集合public static ArrayList<TeamService> teamServices = new ArrayList<TeamService>();   //团队服务对象集合public int getTotal() {return total;}*/
/*查看团队列表方法*//*public static void teamList() {System.out.println("------------------团队列表--------------------");if (teamTotal == 0) {System.out.println("暂无团队,请先添加团队!");} else {System.out.println("当前团队数:" + teamServices.size());for (int i = 0; i < teamTotal; i++) {System.out.println(teams.get(i).toString() +",团队成员:" + teamServices.get(i).total + "/5" + ",开发项目:" + teams.get(i).getJobProject());if (teamServices.get(i).total != 0) {System.out.println("ID\t 姓名\t年龄\t 工资\t 职位\t 状态\t 奖金\t 股票\t 领用设备");for (Programmer p : teamServices.get(i).team) {if ((p != null))System.out.println(p.toString());else break;}}}}}*/
/*添加团队方法*//*public void teamAdd() {if (teamTotal >= 5) {System.out.println("当前团队已经达到上限5个,不可再添加!");return;  //结束方法调用}String teamName = "";w1:while (true) {teamName = TSUtility.readTeamName(6);if (teamTotal > 0) {for (int i = 0; i < teamTotal; i++) {if (teams.get(i).getTeamName().equals(teamName)) {System.out.println("团队名已存在,请重新输入");break;}if (i == teamTotal - 1) {break w1;}}} else {break;}}Team t = new Team(teamCounter, teamName);teams.add(t);//添加元素到arraylist集合TeamService ts = new TeamService();     //给每一个团队建一个teemService对象teamServices.add(ts);teamCounter++;teamTotal++;System.out.println("团队添加成功!");}*/
/*删除团队方法 删除ArrayList中指定下标的元素*//*public void teamDelete() {if (teamTotal == 0) {System.out.println("当前无团队,无法进行删除操作!");} else {System.out.println("请输入要删除的团队id:");int id = TSUtility.readTeamId() - 1;//删除团队时  先将团队成员状态设为trueint l = teamServices.get(id).total;  //获取实际团队人数Programmer[] team1 = teamServices.get(id).team;   //数组中含nullif (l != 0) {System.out.println("删除团队成员信息如下:");System.out.println("ID\t 姓名\t年龄\t 工资\t 职位\t 状态\t 奖金\t 股票\t 领用设备");for (Programmer p : team1) {if (p != null) {p.setStatus(true);System.out.println(p.toString());} else {break;}}}//删除团队时,将正在被此团队开发的项目开发状态 置false,开发团队名称置nullTeam teamDelete = teams.get(id);String delTeamName = teamDelete.getTeamName();  //获取删除的团队名ArrayList<Project> allPro = ProjectService.getAllPro();  //获取所有项目if (allPro.size() != 0) {System.out.println("当前项目数 = " + allPro.size());for (int i = 0; i < allPro.size(); i++) {Project project = allPro.get(i);String pName = project.getTeamName();  //获取项目开发团队名称if (delTeamName.equals(pName)) {project.setTeamName(null);project.setStatus(false);}}}teams.remove(id);teamServices.remove(id);    //删除对应的服务对象for (int i = 0; i < teamTotal - 1; i++) {   //重新对团队进行编号int j = teams.get(i).getTeamId();if (j > id) {teams.get(i).setTeamId(j - 1);}}teamTotal--;teamCounter--;
//            counter = counter-l;    //队内编号System.out.println("团队删除成功!");}}public TeamService() {}//返回team中所有程序员构成的数组public Programmer[] getTeam() {Programmer[] team = new Programmer[total];for (int i = 0; i < total; i++) {team[i] = this.team[i];}return team;}//初始化当前团队成员数组public void clearTeam() {team = new Programmer[MAX_MEMBER];counter=1;total=0;this.team = team;}//增加团队成员public void addMember(Employee e) throws TeamException {if (total >= MAX_MEMBER){throw new TeamException("添加失败!成员已满");}if (!(e instanceof Programmer)) {throw new TeamException("添加失败!该成员不是开发人员,无法添加");}Programmer p = (Programmer)e;if (isExist(p)) {throw new TeamException("添加失败! 该员工已在本团队中");}if(!p.getStatus()) {throw new TeamException("添加失败!该员工已是某团队成员");}int numOfArch = 0, numOfDsgn = 0, numOfPrg = 0;for (int i = 0; i < total; i++) {if (team[i] instanceof Architect) {numOfArch++;}else if (team[i] instanceof Designer){ numOfDsgn++;}else if (team[i] instanceof Programmer){ numOfPrg++;}}if (p instanceof Architect) {if (numOfArch >= 1){throw new TeamException("团队中至多只能有一名架构师");}} else if (p instanceof Designer) {if (numOfDsgn >= 2){throw new TeamException("团队中至多只能有两名设计师");}} else if (p instanceof Programmer) {if (numOfPrg >= 3){throw new TeamException("团队中至多只能有三名程序员");}}//添加到数组p.setStatus(false);p.setMemberId(counter++);team[total++] = p;}private boolean isExist(Programmer p) {for (int i = 0; i < total; i++) {if (team[i].getId() == p.getId()) return true;}return false;}//删除指定memberId的程序员public void removeMember(int memberId) throws TeamException {int n = 0;//找到指定memberId的员工,并删除for (; n < total; n++) {if (team[n].getMemberId() == memberId) {team[n].setStatus(true);break;}}//如果遍历一遍,都找不到,则报异常if (n == total)throw new TeamException("找不到该成员,无法删除");//后面的元素覆盖前面的元素for (int i = n + 1; i < total; i++) {team[i - 1] = team[i];}team[--total] = null;}
}
4、ProjectService:
public class ProjectService {private static ArrayList<Project> pro = new ArrayList<>(); //存放项目的集合private int count = 1;    //项目编号private TeamView TV = new TeamView();//添加项目检测功能 项目是否重复public boolean checkProject(Project p) {boolean result = false;ArrayList<Project> allPro = getAllPro();for (Project project : allPro) {if (project.getProjectName().equals(p.getProjectName())) {System.out.println("项目已存在,请不要重复添加同一项目!");result = true;}}return result;}//添加项目public void addProject() throws InterruptedException {System.out.println("项目参考:--------------------------------------------------");System.out.println("1.小米官网:开发完成类似于小米官网的web项目.");System.out.println("2.公益在线商城:猫宁Morning公益商城是中国公益性在线电子商城.");System.out.println("3.博客系统:Java博客系统,让每一个有故事的人更好的表达想法!");System.out.println("4.在线协作文档编辑系统:一个很常用的功能,适合小组内的文档编辑。");System.out.println("------------------------------------------------------------");TSUtility.readReturn();  //回车键继续System.out.println("请输入你想添加的项目名:(项目编号) ");char c = TSUtility.readMenuSelection();switch (c) {case '1':Project p1 = new Project();p1.setProId(1);p1.setProjectName("小米官网");p1.setDesName("开发完成类似于小米官网的web项目.");if (checkProject(p1) == false) {pro.add(p1);//     TSUtility.loadSpecialEffects();   //进度加载条System.out.println("已添加项目:" + p1.getProjectName());}break;case '2':Project p2 = new Project();p2.setProId(2);p2.setProjectName("公益在线商城");p2.setDesName("猫宁Morning公益商城是中国公益性在线电子商城.");if (checkProject(p2) == false) {pro.add(p2);//    TSUtility.loadSpecialEffects();   //进度加载条System.out.println("已添加项目:" + p2.getProjectName());}break;case '3':Project p3 = new Project();p3.setProId(3);p3.setProjectName("博客系统");p3.setDesName("Java博客系统,让每一个有故事的人更好的表达想法!");if (checkProject(p3) == false) {pro.add(p3);// TSUtility.loadSpecialEffects();   //进度加载条System.out.println("已添加项目:" + p3.getProjectName());}break;case '4':Project p4 = new Project();p4.setProId(4);p4.setProjectName("在线协作文档编辑系统");p4.setDesName("一个很常用的功能,适合小组内的文档编辑。");if (checkProject(p4) == false) {pro.add(p4);// TSUtility.loadSpecialEffects();   //进度加载条System.out.println("已添加项目:" + p4.getProjectName());}break;default:System.out.println("项目不存在");break;}}//给项目分配团队(指定分配)public void dealingPro(int id, int id2) {Project project = pro.get(id);  //获取当前待分配项目Team team = teams.get(id2);  //获取分配团队名称project.setTeamName(team.getTeamName());Programmer[] p = teamServices.get(id2).getTeam();   //获取开发团队project.setTeam(p);project.setStatus(true);pro.set(id, project);  //修改项目集合ArrayList中对应索引项目的值System.out.println("分配成功!项目指定给了团队<" + team.getTeamName() + ">开发");//设置当前分配的开发团队正在开发此项目team.setJobProject(project.getProjectName());
//        System.out.println("该开发团队成员如下:");
//        for (Programmer p1 :p){
//            System.out.println(p1.getName());
//        }}//给项目分配团队(随机分配)public void dealingPro(int id) { //传入待分配项目idProject project = pro.get(id);  //获取当前待分配项目Random r = new Random();int id2 = r.nextInt(teamServices.size());Team team;if (id2 >= 1 && id2 <= teamServices.size()) {team = teams.get(id2);int n = -1;do {n = TeamService.teamServices.get(id2).getTotal();// 判断当前分配团队是否已有项目在开发if (teamJobProject(TeamService.teams.get(id2 - 1))) {System.out.println("当前团队正在开发项目,请重新分配!");return;}System.out.println("当前分配团队人数:" + n);if (n == 0) {System.out.println("Id为" + (id2 + 1) + "的团队没有开发成员,请先添加开人员!");TV.enterMainMenu();} else {break;}} while (true);} else {System.out.println("团队不存在");return;}project.setTeamName(team.getTeamName());Programmer[] p = teamServices.get(id2).getTeam();   //获取开发团队project.setTeam(p);     //将开发团队存储到项目信息中project.setStatus(true);pro.set(id, project);  //修改项目集合ArrayList中对应索引项目的值System.out.println("分配成功!项目随机分配给了团队<" + team.getTeamName() + ">开发");//设置当前分配的开发团队正在开发此项目team.setJobProject(project.getProjectName());//随机获取项目
//        Random r = new Random();
//        int proNum = r.nextInt(pro.size());     //获取不大于项目数的随机数proNum
//        Project project = this.pro.get(proNum);    //随机获取一个项目}//查看目前项目情况public void showPro() throws InterruptedException {// TSUtility.loadSpecialEffects();System.out.println("-----------------项目列表-----------------");if (pro.size() == 0) {System.out.println("暂无项目,请先添加项目!");} else {for (int i = 0; i < pro.size(); i++) {System.out.println(pro.get(i));if (pro.get(i).getStatus() == true) {System.out.println("项目" + pro.get(i).getProjectName() + "------正在被团队" + pro.get(i).getTeamName() + "开发");} else {System.out.println("项目" + pro.get(i).getProjectName() + "------未开发");}}}}//删除选择的项目public void delPro(int id) {*/
/*   String projectTeamName = pro.get(id).getTeamName();  //获取即将删除的项目开发团队名称if (projectTeamName != null) {  //项目开发团队不为null时进入//遍历团队,将在开发此即将删除项目的团队 的开发项目置nullfor (Team team : teams) {if (team.getTeamName().equals(projectTeamName)) {  //找到正在开发此项目的团队team.setJobProject(null);       //将开发项目设置为null}}}*//*if(id < 0 || id > pro.size()){System.out.println("输入的id不存在!");return;}boolean flag = false;for (int i = 0; i < pro.size(); i++) {if (pro.get(i).getProId() == id) {pro.remove(i);for (i = id; i <= pro.size(); i++) {pro.get(i - 1).setProId(pro.get(i - 1).getProId() - 1);}flag = true;}}if (flag) {System.out.println("删除成功!");count--;} else {try {throw new TeamException("该项目不存在");} catch (TeamException e) {e.printStackTrace();}}}//得到所有项目数据集合public static ArrayList<Project> getAllPro() {return pro;}}
5、IndexView,主菜单界面:
public class IndexView {// 颜色特效public static final String ANSI_RESET = "\u001B[0m";public static final String ANSI_GREEN = "\u001B[32m";public static final String ANSI_YELLOW = "\u001B[33m";public static final String ANSI_PURPLE = "\u001B[35m";public static final String ANSI_BLUE = "\u001B[34m";public static final String ANSI_CYAN = "\u001B[36m";private LoginView loginVi = new LoginView();private NameListService nameListSer = new NameListService();private TeamView teamVi = new TeamView();private ProjectService projectSer = new ProjectService();private ArrayList<Team> manyTeam=null;public  void menu() throws InterruptedException {boolean loopFlag = true;char key = 0;System.out.println(ANSI_PURPLE);System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");System.out.println("🔣                                        🔣");System.out.println("🔣    欢迎来到项目开发团队分配管理软件     🔣");System.out.println("🔣                                        🔣");System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");System.out.println("🐕");System.out.println("🐕");System.out.println("🐕");System.out.println("🐕-----------<请您先进行登录>-------------🐕");TSUtility.readReturn();try {loginVi.login();} catch (InterruptedException e) {e.printStackTrace();}do {System.out.println(ANSI_RESET + ANSI_CYAN);System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");System.out.println("🔣                                         🔣");System.out.println("🔣              ~软件主菜单~               🔣");System.out.println("🔣                                         🔣");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("⬇请选择:  ");System.out.print(ANSI_RESET);key = TSUtility.readMenuSelectionPro();switch (key) {case '1':try {loginVi.update();} catch (InterruptedException e) {e.printStackTrace();}break;case '2':try {nameListSer.showEmployee();} catch (InterruptedException e) {e.printStackTrace();}boolean loopFlagSec = true;char keySec = 0;do {System.out.print(ANSI_RESET + ANSI_YELLOW);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("⬇请选择:  ");keySec=TSUtility.readMenuSelectionPro();switch (keySec) {case '1':try {nameListSer.addEmployee();} catch (InterruptedException e) {e.printStackTrace();}break;case '2':try {nameListSer.showEmployee();} catch (InterruptedException e) {e.printStackTrace();}break;case '3':System.out.println("请输入需要修改的员工id:");int i = TSUtility.readInt();try {nameListSer.modifyEmployee(i);} catch (InterruptedException e) {e.printStackTrace();}break;case '4':System.out.println("请输入需要删除的员工id:");int j  = TSUtility.readInt();nameListSer.delEmployee(j);break;case '5':System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlagSec = false;}break;default:System.out.println("输入有误!请重新输入!");break;}} while (loopFlagSec);break;case '3'://开发团队调度teamVi.TeamControl();//  manyTeam = teamVi.getManyTeam();break;case '4':boolean loopFlagThr = true;char keyThr = 0;do {System.out.print(ANSI_RESET + ANSI_GREEN);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("⬇请选择:  ");System.out.print(ANSI_RESET + ANSI_YELLOW);keyThr=TSUtility.readMenuSelectionPro();switch (keyThr) {case '1':try {projectSer.addProject();} catch (InterruptedException e) {e.printStackTrace();}break;case '2':if (projectSer.getAllPro().size() == 0){System.out.println("当前无项目,请先添加项目!");break;}manyTeam = TeamService.teams;    //获取团队集合if (manyTeam.size() == 0) {System.out.println("当前无开发团队,请先添加团队!");teamVi.TeamControl();}TeamService.teamList();  //展示团队列表projectSer.showPro(); //展示项目列表distribution();   //调用分配方法case '3':try {projectSer.showPro();} catch (InterruptedException e) {e.printStackTrace();}break;case '4':ArrayList<Project> p = projectSer.getAllPro();if (p.size() == 0) {System.out.println("暂无项目,无法进行项目删除操作!");} else {System.out.println("请输入需要删除的项目id:");int j = TSUtility.readInt();projectSer.delPro(j);}break;case '5':System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlagThr = false;}break;default:System.out.println("输入有误!请重新输入!");break;}} while (loopFlagThr);break;case '5':System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlag = false;}break;default:break;}} while (loopFlag);}//判断待分配项目是否已在开发public static boolean projectIsRun(Project project){if (project.getTeamName() != null){System.out.println("当前项目正在被团队<"+project.getTeamName()+">开发,终止本次分配。");return true;}else{return false;}}//判断当前分配团队是否已有项目在开发public static boolean teamJobProject(Team team) {if (team.getJobProject() != null) {return true;} else {return false;}}
//    分配方式选择方法,指定/随机
public void distribution() {System.out.println("请选择分配方式:(A.指定团队开发  B.随机分配团队开发  T.进入团队管理)");char choose = TSUtility.readDistributionChoose();//进入团队管理)if (choose == 'T'){teamVi.TeamControl();return;}//项目分配System.out.println("请输入要分配给团队开发的项目id:");int id = -1;do {id = TSUtility.readInt();if (id > ProjectService.getAllPro().size()){System.out.println("输入id大于现有项目数,请重新输入:");}else{id =id-1;   //赋值为地址索引break;}}while (true);//A.指定团队开发if (choose == 'A') {System.out.println("请输入要分配的团队id");int id2 = -1;do {id2 = TSUtility.readInt();if (id2 > TeamService.teams.size()){System.out.println("输入id大于现有团队数,请重新输入:");}else{id2 =id2-1;   //赋值为地址索引break;}}while (true);int n = -1;do {n = TeamService.teamServices.get(id2).getTotal();System.out.println("当前分配团队人数:"+n);if (n == 0) {System.out.println("Id为"+(id2+1)+"的团队没有开发成员,请先添加开人员!");teamVi.enterMainMenu();}else{break;}}while(true);//调用带参分配方法 给项目指定团队开发projectSer.dealingPro(id, id2);}//B.随机分配团队开发if (choose == 'B') {//调用无参分配方法 给指定项目 随机分配团队开发projectSer.dealingPro(id);}
}
public static void main(String[] args) throws InterruptedException {new IndexView().menu();}}
6、TSUtility工具类:
public class TSUtility {private static Scanner scanner = new Scanner(System.in);public static char readMenuSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false);c = str.charAt(0);if (c != '1' && c != '2' &&c != '3' && c != '4') {System.out.print("选择错误,请重新输入:");} else break;}return c;}public static char readDistributionChoose() {char c;for (; ; ) {String str = readKeyBoard(1, false).toUpperCase();c = str.charAt(0);if (c == 'A' || c == 'B'|| c == 'T') {break;} else {System.out.print("选择错误,请重新输入:");}}return c;}public static char readMenuSelectionPro() {char c;for (; ; ) {String str = readKeyBoard(1, false);c = str.charAt(0);if (c != '1' && c != '2' &&c != '3' && c != '4' && c != '5') {System.out.print("选择错误,请重新输入:");} else break;}return c;}public static void readReturn() {System.out.print("按回车键继续...");readKeyBoard(100, true);}public static int readInt() {int n;for (; ; ) {String str = readKeyBoard(2, false);try {n = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("数字输入错误,请重新输入:");}}return n;}public static int readstock() {int n;for (; ; ) {String str = readKeyBoard(6, false);try {n = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("数字输入错误,请重新输入:");}}return n;}public static Double readDouble() {Double n;for (; ; ) {String str = readKeyBoard(6, false);try {n = Double.parseDouble(str);break;} catch (NumberFormatException e) {System.out.print("数字输入错误,请重新输入:");}}return n;}public static char readConfirmSelection() {char c;for (; ; ) {String str = readKeyBoard(1, false).toUpperCase();c = str.charAt(0);if (c == 'Y' || c == 'N') {break;} else {System.out.print("选择错误,请重新输入:");}}return c;}public static String readString(int limit, String defaultValue) {String str = readKeyBoard(limit, true);return str.equals("")? defaultValue : str;}public static String readKeyBoard(int limit, boolean blankReturn) {String line = "";while (scanner.hasNextLine()) {line = scanner.nextLine();if (line.length() == 0) {if (blankReturn) return line;else continue;}if (line.length() < 1 || line.length() > limit) {System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");continue;}break;}return line;}public static void loadSpecialEffects() throws InterruptedException {System.out.println("请稍等:");for (int i1 = 1; i1 <= 100; i1++) {System.out.print("加载中:" + i1 + "%");Thread.sleep(new Random().nextInt(25) + 1);if (i1 == 100) {Thread.sleep(50);}System.out.print("\r");}}public static int readTeamId() {//        System.out.println("请输入要删除的团队id:");int teamId;for (; ; ) {String str = readKeyBoard(1, false);try {teamId = Integer.parseInt(str);break;} catch (NumberFormatException e) {System.out.print("数字输入错误,请重新输入:");}}return teamId;}public static String readTeamName(int limit) {Scanner sc = new Scanner(System.in);System.out.println("请输入团队名:");String name = "";for (; ; ) {name = sc.next();if (name.length() > limit) {System.out.println("团队名长度不能大于+" + limit + ",请重新输入:");} else {break;}}return name;}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com