项目开发团队分配管理软件
一、需求说明
- 该软件实现以下功能: 软件启动时,首先进入登录界面进行注册和登录功能。
- 当登陆成功后,进入菜单,首先就可以对开发人员账户和密码进行修改。
- 然后可以对开发人员进行增删改操作
- 人员添加成功后,根据菜单提示,基于现有的公司成员,组建一个开发团队以开发一个新的项目。
- 组建过程包括将成员插入到团队中,或从团队中删除某成员,还可以列出团队中现有成员的列表,开发团队成员包括架构师、设计师和程序员。
- 团队组建成功,则可以进入项目模块,添加项目,分配开发团队进行开发。
1.1、用户注册和登录模块
- 定义一个LoginView类
- 实现注册方法
- 如果没有账户则需要注册
- 如果有账号则直接进行登录
- 实现登录功能
- 判断用户输入的值是否正确
- 如果正确则进入软件菜单 如果错误则重新输入,限制次数只有5次,超过次数则程序停止,重新启动
- 实现修改用户密码功能
- 可以实现对用户名,密码,或者两者都可以进行修改即可。
package com.team.view;public class LoginView {private String userName = "";private String password = "";//实现注册方法public void registView() {System.out.println("开始注册:");System.out.println("请输入你的注册账户名称:");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("请输入你的注册密码:");String password = TSUtility.readKeyBoard(16, false);this.password = password;System.out.println("注册成功!请登录!");}//实现登录功能public void login() throws InterruptedException {int count = 3;boolean flag = true;while (flag) {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("请输入你的登录账户名称:");String userName = TSUtility.readKeyBoard(4, false);System.out.println("请输入你的登录密码:");String password = TSUtility.readKeyBoard(16, false);//未注册if (this.userName.length() == 0 || this.password.length() == 0) {System.out.println("未检测到您的账号,请您先注册!");registView();} 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 + "次,请重新输入:");System.out.println("---------------------------------");System.out.println();}}}}//实现修改用户密码功能public void revise() 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("🐱*** ***🐱");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("请输入(1-4)");int chishu = TSUtility.readInt();switch (chishu) {case 1:System.out.println("请输入你的修改的账户名称(" + getUserName() + "):");String userName = TSUtility.readKeyBoard(4, false);this.userName = userName;System.out.println("修改成功!");break;case 2:System.out.println("请输入你的修改密码(" + getPassword() + "):");String password = TSUtility.readKeyBoard(16, false);this.password = password;System.out.println("修改成功!");break;case 3:System.out.println("请输入你的修改的账户名称(" + getUserName() + "):");String userName1 = TSUtility.readKeyBoard(4, false);this.userName = userName1;System.out.println("请输入你的修改密码(" + getPassword() + "):");String password1 = TSUtility.readKeyBoard(16, false);this.password = password1;System.out.println("修改成功!");break;case 4:System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {flag = false;TSUtility.loadSpecialEffects();System.out.println("退出成功");return;}default:System.out.println("输入错误!请输入(1-4)");break;}}}public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}}
2、开发人员管理模块
- 在domain包中完成各个类的实体类创建
- Architect架构师实体类
package com.team.domain;public class Architect extends Designer{//stock 表示公司奖励的股票数量private int stock;public Architect(int id, String name, int age, double salary, Equipment equipment, double bonus, int stock) {super(id, name, age, salary, equipment, bonus);this.stock = stock;}public int getStock() {return stock;}public void setStock(int stock) {this.stock = stock;}@Overridepublic String toString() {return ObjectProperties() + "\t架构师\t" +isStatus()+ "\t" + getBonus() + "\t" + getStock() + "\t" + getEquipment().getDescription();}
}
- Designer 设计师实体类
package com.team.domain;public class Designer extends Programmer {//bonus 表示奖金private double bonus;public Designer() {}public Designer(int id, String name, int age, double salary, Equipment equipment, double bonus) {super(id, name, age, salary, equipment);this.bonus = bonus;}public double getBonus() {return bonus;}public void setBonus(double bonus) {this.bonus = bonus;}@Overridepublic String toString() {return ObjectProperties() + "\t设计师\t" + isStatus() + "\t" + getBonus() + "\t\t\t" + getEquipment().getDescription();}}
-
Employee 人员类
-
package com.team.domain;public class Employee {private int id;private String name;private int age;private double salary;public Employee() {}public Employee(int id, String name, int age, double salary) {this.id = id;this.name = name;this.age = age;this.salary = salary;}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 int getAge() {return age;}public void setAge(int age) {this.age = age;}public double getSalary() {return salary;}public void setSalary(double salary) {this.salary = salary;}public String ObjectProperties() {return id + "\t" + name + "\t" + age + "\t\t" + salary;}@Overridepublic String toString() {return ObjectProperties();} }
- 在NameListService类中完成功能操作
- 实现员工的添加(根据职业添加(无,程序员,设计师,架构师))
- 实现员工的查看 (显示所有数据)
- 实现员工的删除(注意员工id需要动态显示,也就是删除后,员工id需要更新)
- 实现员工的修改(至少修改员工的姓名,年龄,工资)
package com.team.service;import com.team.domain.*;
import com.team.view.TSUtility;import java.util.ArrayList;
import java.util.Scanner;public class NameListService {private ArrayList<Employee> employees = new ArrayList<>();private int orderNumber = 1;public Scanner sc = new Scanner(System.in);public NameListService() {}//初始化{employees.add(new Employee(orderNumber, "马云 ", 22, 3000));employees.add(new Architect(++orderNumber, "马化腾", 32, 18000, new NoteBook("联想T4", 6000), 60000, 5000));employees.add(new Programmer(++orderNumber, "李彦宏", 23, 7000, new PC("戴尔", "NEC 17寸")));employees.add(new Programmer(++orderNumber, "刘强东", 24, 7300, new PC("戴尔", "三星 17寸")));employees.add(new Designer(++orderNumber, "雷军 ", 50, 10000, new Printer("激光", "佳能2900"), 5000));employees.add(new Programmer(++orderNumber, "任志强", 30, 16800, new PC("华硕", "三星 17寸")));employees.add(new Designer(++orderNumber, "柳传志", 45, 35500, new PC("华硕", "三星 17寸"), 8000));employees.add(new Architect(++orderNumber, "杨元庆", 35, 6500, new Printer("针式", "爱普生20k"), 15500, 1200));employees.add(new Designer(++orderNumber, "史玉柱", 27, 7800, new NoteBook("惠普m6", 5800), 1500));employees.add(new Programmer(++orderNumber, "丁磊 ", 26, 6600, new PC("戴尔", "NEC17寸")));employees.add(new Programmer(++orderNumber, "张朝阳 ", 35, 7100, new PC("华硕", "三星 17寸")));employees.add(new Designer(++orderNumber, "杨致远", 38, 9600, new NoteBook("惠普m6", 5800), 3000));}//getAllEmployees ()方法:获取当前所有员工。//返回:包含所有员工集合public ArrayList<Employee> getAllEmployees() {return employees;}//getEmployee(id : int)方法:获取指定ID的员工对象。//参数:指定员工的ID//返回:指定员工对象//异常:找不到指定的员工public Employee getEmployee(int id) throws TeamException {boolean flag = true;for (int i = 0; i < employees.size(); i++) {if (employees.get(i).getId() == id) {flag = false;return employees.get(i);}}while (flag) {try {throw new TeamException("找不到指定的员工");} catch (TeamException e) {e.printStackTrace();System.out.println("请重新输入指定员工的ID");int id1 = TSUtility.readInt();getEmployee(id1);return employees.get(id1 - 1);}}return employees.get(0);}//实现员工的添加(根据职业添加(无,程序员,设计师,架构师))public void addEmployee() throws InterruptedException {System.out.println("请输入需要添加的雇员的职位:");System.out.println("1(无职位)");System.out.println("2(程序员)");System.out.println("3(设计师)");System.out.println("4(架构师)");String c = String.valueOf(TSUtility.readMenuSelection());switch (c) {case "1":System.out.println("`当前雇员职位分配为:无`");System.out.println("请输入当前雇员的姓名:");String name = TSUtility.readKeyBoard(4, false);System.out.println("请输入当前雇员的年龄:");int age = TSUtility.readInt();System.out.println("请输入当前雇员的工资:");Double salary = TSUtility.readDouble();Employee employee = new Employee(++orderNumber, name, age, salary);employees.add(employee);System.out.println("人员添加成功!");TSUtility.readReturn();break;case "2":System.out.println("`当前雇员职位分配为:程序员`");System.out.println("请输入当前雇员的姓名:");String name1 = TSUtility.readKeyBoard(4, false);System.out.println("请输入当前雇员的年龄:");int age1 = TSUtility.readInt();System.out.println("请输入当前雇员的工资:");Double salary1 = TSUtility.readDouble();System.out.println("请为当前程序员配一台好的台式电脑:");PC pc = new PC().addPC();Programmer programmer = new Programmer(++orderNumber, name1, age1, salary1, pc);employees.add(programmer);System.out.println("人员添加成功!");TSUtility.readReturn();break;case "3":System.out.println("`当前雇员职位分配为:设计师`");System.out.println("请输入当前雇员的姓名:");String name2 = TSUtility.readKeyBoard(4, false);System.out.println("请输入当前雇员的年龄:");int age2 = TSUtility.readInt();System.out.println("请输入当前雇员的工资:");Double salary2 = TSUtility.readDouble();System.out.println("请为当前设计师配一台好的笔记本电脑:");NoteBook noteBook = new NoteBook().addNoteBook();System.out.println("请输入当前设计师的奖金:");Double bonus = TSUtility.readDouble();Designer designer = new Designer(++orderNumber, name2, age2, salary2, noteBook, bonus);employees.add(designer);System.out.println("人员添加成功!");TSUtility.readReturn();break;case "4":System.out.println("`当前雇员职位分配为:架构师`");System.out.println("请输入当前雇员的姓名:");String name3 = TSUtility.readKeyBoard(4, false);System.out.println("请输入当前雇员的年龄:");int age3 = TSUtility.readInt();System.out.println("请输入当前雇员的工资:");Double salary3 = TSUtility.readDouble();System.out.println("请为当前架构师配一台好的打印设备:");Printer printer = new Printer().addPrinter();System.out.println("请输入当前架构师的奖金:");Double bonus1 = TSUtility.readDouble();System.out.println("请输入当前架构师的股票:");Integer stock = TSUtility.readstock();Architect architect = new Architect(++orderNumber, name3, age3, salary3, printer, bonus1, stock);employees.add(architect);System.out.println("人员添加成功!");TSUtility.readReturn();break;default:System.out.println("重新输入");addEmployee();}}//实现员工的修改(至少修改员工的姓名,年龄,工资)public void changeEmployee(int id) throws InterruptedException {boolean flag = false;for (int i = 0; i < employees.size(); i++) {Employee emp = employees.get(i);if (employees.get(i).getId() == id) {System.out.print("姓名(" + emp.getName() + "):");String name = TSUtility.readString(4, emp.getName());System.out.print("年龄(" + emp.getAge() + "):");int age = Integer.parseInt(TSUtility.readString(2, emp.getAge() + ""));System.out.print("工资(" + emp.getSalary() + "):");double salary = Double.parseDouble(TSUtility.readString(10, emp.getSalary() + ""));emp.setName(name);emp.setAge(age);emp.setSalary(salary);employees.set(i, emp);flag = true;}}if (flag) {System.out.println("修改成功!");} else {try {throw new TeamException("找不到指定的员工");} catch (TeamException e) {e.printStackTrace();System.out.println("请重新输入指定员工的ID");int id1 = TSUtility.readInt();changeEmployee(id1);}}}//实现员工的删除(注意员工id需要动态显示,也就是删除后,员工id需要更新)public void delEmployee(int id) throws InterruptedException {boolean flag = false;for (int i = 0; i < employees.size(); i++) {if (employees.get(i).getId() == id) {employees.remove(i);for (i = id; i <= employees.size(); i++) {employees.get(i - 1).setId(employees.get(i - 1).getId() - 1);}flag = true;}}if (flag) {System.out.println("删除成功!");orderNumber--;} else {try {throw new TeamException("该员工不存在");} catch (TeamException e) {e.printStackTrace();System.out.println("请重新输入指定员工的ID");int id1 = TSUtility.readInt();delEmployee(id1);}}}//查看员工列表public void showEmployee() throws InterruptedException {TSUtility.loadSpecialEffects();System.out.println("ID\t 姓名\t年龄\t 工资\t 职位\t 状态\t 奖金\t 股票\t 领用设备");for (int i = 0; i < employees.size(); i++) {System.out.println(" " + employees.get(i));}}
}
3、开发团队调度管理模块
package com.team.view;import com.team.domain.Employee;
import com.team.domain.Programmer;
import com.team.domain.Project;
import com.team.service.NameListService;
import com.team.service.ProjectService;
import com.team.service.TeamException;
import com.team.service.TeamService;import java.util.ArrayList;public class TeamView {private NameListService ListSvc = new NameListService();private TeamService teamSvc = new TeamService();ArrayList<Programmer[]> team = new ArrayList<>();//进入界面public void enterMainMenu() throws TeamException {boolean loopFlag = true;char key = 0;do {if (key != '1') {listAllEmlpoyees();}System.out.println("1-团队列表 2-添加团队成员 3-删除团队成员 4-退出");System.out.print("请选择(1-4)");key = TSUtility.readMenuSelection();System.out.println();switch (key) {case '1':ListTeam();break;case '2':addMember();break;case '3':deleteMember();break;case '4':System.out.println("请确认是否要退出(Y/N)");char ch = TSUtility.readConfirmSelection();if (ch == 'Y') {team.add(teamSvc.getTeam());teamSvc.clearTeam();loopFlag = false;}break;default:System.out.println("输入信息有误,请重新输入");break;}} while (loopFlag);}//显示所有员工成员private void listAllEmlpoyees() {System.out.println("\n-----------------------开发团队调度软件----------------------------\n");ArrayList<Employee> emps = ListSvc.getAllEmployees();if (emps.size() == 0) {System.out.println("无客户记录。");} else {System.out.println("ID\t\t\t姓名\t\t年龄\t\t工资\t\t职位\t\t状态\t\t奖金\t\t股票\t\t领用设备");}for (Employee e : emps) {//增强for循环System.out.println(" " + e);}System.out.println("--------------------------------------------------------------------");}//显示开发团队成员列表private void ListTeam() {System.out.println("--------------团队成员列表------------");Programmer[] team = teamSvc.getTeam();if (team.length == 0) {System.out.println("开发团队目前没有成员");} else {System.out.println("TID\t\t姓名\t\t年龄\t工资\t职位\t奖金\t股票");}//增强for循环System.out.println("---------------------------------");for (Programmer p : team) {System.out.println(" " + p.toString());}System.out.println("----------------------------------");}//添加成员到团队private void addMember() throws TeamException {System.out.println("-------------添加团队成员-------------------");System.out.println("请输入要添加的成员ID");int id = TSUtility.readInt();try {Employee e = ListSvc.getEmployee(id);teamSvc.addMember(e);System.out.println("添加成功");} catch (TeamException e) {System.out.println("添加失败,原因是" + e.getMessage());}//回车继续TSUtility.readReturn();}//从团队中删除指定位置的成员private void deleteMember() {System.out.println("--------------删除成员-------------");System.out.println("请入要删除的员工TID");int TID = TSUtility.readInt();if (TID < 1) {try {throw new TeamException("不存在该员工的TID");} catch (TeamException e) {System.out.println(e.getMessage());}}System.out.println("请确认是否删除(Y/N)");char yn = TSUtility.readConfirmSelection();if (yn == 'N') {return;}try {teamSvc.removeMember(TID);System.out.println("删除成功");} catch (TeamException e) {System.out.println("删除失败,原因是" + e.getMessage());}TSUtility.readReturn();}//加入并得到更多的团队public ArrayList<Programmer[]> getManyteam() throws TeamException {boolean flag = true;char key = 0;do {System.out.println("***************************");System.out.println("** **");System.out.println("** 团队调度界面 **");System.out.println("** **");System.out.println("***************************");System.out.println("1-添加团队 2-查看团队 3-删除团队 4-退出");System.out.print("请选择(1-4)");key = TSUtility.readMenuSelection();switch (key) {case '1':enterMainMenu();break;case '2'://加强for循环该怎么用System.out.println("-----团队列表-----");for (Programmer[] team : team) {for (int i = 0; i < team.length; i++) {System.out.println(team[i]);}System.out.println("------------");teamSvc.clearTeam();}if (team.size() == 0) {System.out.println("当前无团队,请先添加团队");}break;case '3':if (team.size() == 0) {try {throw new TeamException("当前无团队,请先添加团队");} catch (TeamException e) {System.out.println(e.getMessage());}}if (team.size() != 0) {System.out.println("请输入要删除第几个团队");int num = TSUtility.readstock();if (num <= team.size()) {System.out.print("请确认是否删除(Y/N)");char de = TSUtility.readConfirmSelection();if (de == 'Y') {//释放团队Programmer[] programmer =team.get(num-1);for (int i = 0; i <team.get(num-1).length ; i++) {programmer[i].setStatus(true);}team.remove(num-1);//释放团队名称Project project = ProjectService.getPro().get(num-1);project.setTeam(new Programmer[0]);project.setTeamName(null);project.setStatus(false);ProjectService.getPro().set(num-1,project);} else {System.out.println("请考虑清楚");}} else {System.out.println("没有该团队,请正常输入!" + "目前团队只有" + team.size() + "个");}}break;case '4':System.out.println("是否退出(Y/N)");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {
// team.add(teamSvc.getTeam());flag = false;}break;default:System.out.println("输入信息有误,请重新输入");break;}} while (flag);return team;}
}
4、开发项目管理模块
package com.team.domain;public class Project {// 项目号 proId int-private int proID;// 项目名称 projectName Stringprivate String projectName;//- 项目描述 desName Stringprivate String desName;//- 开发团队 team Programmer[]-private Programmer[] team = new Programmer[10];//开发团队名称 teamName String-private String teamName;// 开发状态 status false(true为开发中,false为未开发中))private boolean status = false;public Project() {}public Project(int proID, String projectName, String desName, Programmer[] team, String teamName, boolean status) {this.proID = proID;this.projectName = projectName;this.desName = desName;this.team = team;this.teamName = teamName;this.status = status;}public int getProID() {return proID;}public void setProID(int proID) {this.proID = proID;}public String getProjectName() {return projectName;}public void setProjectName(String projectName) {this.projectName = projectName;}public String getDesName() {return desName;}public void setDesName(String desName) {this.desName = desName;}public Programmer[] getTeam() {return team;}public void setTeam(Programmer[] team) {this.team = team;}public String getTeamName() {return teamName;}public void setTeamName(String teamName) {this.teamName = teamName;}public boolean isStatus() {return status;}public void setStatus(boolean status) {this.status = status;}@Overridepublic String toString() {return proID + "\t" + "项目名称:" + projectName + "\t 内容为:" + desName + "\t团队名称" + teamName + "开发状态是:" + status;}
}
5、IndexView类的设计
package com.team.view;
import com.team.domain.Programmer;
import com.team.service.NameListService;
import com.team.service.ProjectService;
import com.team.service.TeamException;import java.util.ArrayList;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<Programmer[]> manyTeam=null;public ProjectService getProjectSer() {return projectSer;}public void setProjectSer(ProjectService projectSer) {this.projectSer = projectSer;}public void menu() throws InterruptedException, TeamException {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("🐕");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("🔣 🔣");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.revise();} 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.changeEmployee(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;}default:System.out.println("输入有误!请重新输入!");break;}} while (loopFlagSec);break;case '3':try{manyTeam=teamVi.getManyteam();}catch (Exception e){e.printStackTrace();}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':try {if (manyTeam==null){System.out.println("没有团队,请先添加团队");}else {if (projectSer.getPro().size()==0){System.out.println("有"+manyTeam.size()+"个团队,没项目,请先添加项目");} else if (projectSer.getPro().size()<manyTeam.size()) {System.out.println("请再去添加"+(manyTeam.size()-projectSer.getPro().size())+"个项目任务");} else {for (Programmer[] pro : manyTeam) {projectSer.dealingPro(pro);}}}}catch (NullPointerException e){e.printStackTrace();}break;case '3':try {projectSer.showPro();} catch (InterruptedException e) {e.printStackTrace();}break;case '4':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 void main(String[] args) throws InterruptedException, TeamException {new IndexView().menu();}
}
其他代码已打包放入百度网盘里
链接:https://pan.baidu.com/s/1k1JlMkF733uZOWHGWFRINw
提取码:2202
总结
在删除队伍团队的时候需要释放团队里的团队成员,并且也需要释放相对应的团队名称的信息。在运行的时候将可能出现的问题即使应用try,catch来进行把任务接收进行对其的更改。对于随机分配项目的时候需要考虑有重复的分配,导致不能将全部的任务进行分配。