一、目标

1.模拟实现一个基于文本界面的《项目开发团队分配管理软件》;

2.熟悉Java面向对象的高级特性,进一步掌握编程技巧和调试技巧。

3.主要涉及以下知识点: 类的继承性和多态性

对象的值传递、接口;

static和final修饰符;

特殊类的使用:包装类、抽象类、内部类;

异常处理;

Java基本语法和流程控制;

数组,ArrayList集合。

二、需求说明

1.软件启动时,首先进入登录界面进行注册和登录功能。

2.当登陆成功后,进入菜单,首先就可以对开发人员账户和密码进行修改。

3.然后可以对开发人员进行增删改操作

4.人员添加成功后,根据菜单提示,基于现有的公司成员,组建一个开发团队以开发一个新的项目。

5.组建过程包括将成员插入到团队中,或从团队中删除某成员,还可以列出团队中现有成员的列表,开发团队成员包括架构师、设计师和程序员。

6.团队组建成功,则可以进入项目模块,添加项目,分配开发团队进行开发。

三、软件设计结构

四、系统功能结构

五、系统流程图

六、domain包

1.Employee类

package 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 getAge() {return age;}public void setAge(int age) {this.age = age;}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 double getSalary() {return salary;}public void setSalary(double salary) {this.salary = salary;}protected String getDetails() {return id + "\t" + name + "\t" + age + "\t\t" + salary;}@Overridepublic String toString() {return getDetails();}
}

2.Programmer类

package domain;public class Programmer extends Employee {//程序员private int memberId;//用来记录成员加入开发团队后在团队中的IDprivate boolean status = true;//项目中人员的状态,先赋值为true,当添加到团队时为falseprivate Equipment equipment;//表示该成员领用的设备public Programmer() {}public Programmer(int id, String name, int age,double salary, Equipment equipment) {super(id, name, age, salary);this.equipment = equipment;}public Boolean getStatus() {return status;}public void setStatus(Boolean status) {this.status = status;}public Equipment getEquipment() {return equipment;}public void setEquipment(Equipment equipment) {this.equipment = equipment;}public int getMemberId() {return memberId;}public void setMemberId(int memberId) {this.memberId = memberId;}protected String getMemberDetails() {return getMemberId() + "/" + getDetails();}public String getDetailsForTeam() {return getMemberDetails() + "\t程序员";}@Overridepublic String toString() {return getDetails() + "\t程序员\t" + status + "\t\t\t\t\t" + equipment.getDescription();}
}

3.Designer类

package domain;public class Designer extends Programmer{//设计师类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;}public String getDetailsForTeam() {return getMemberDetails() + "\t设计师\t" + getBonus();}@Overridepublic String toString() {return getDetails() + "\t设计师\t" + getStatus() + "\t" +getBonus() +"\t\t\t" + getEquipment().getDescription();}
}

4.Architect类

package domain;public class Architect extends Designer {//架构师类private int stock;//股票public Architect() {}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 getDetailsForTeam() {return getMemberDetails() + "\t架构师\t" +getBonus() + "\t" + getStock();}@Overridepublic String toString() {return getDetails() + "\t架构师\t" + getStatus() + "\t" +getBonus() + "\t" + getStock() + "\t" + getEquipment().getDescription();}
}

5.Equipment接口

package domain;public interface Equipment {public String getDescription();
}

6.NoteBook类(TSUtility类在view包)

package domain;import view.TSUtility;//笔记本电脑
public class NoteBook implements Equipment {private String model;//机器的型号private double price;//价格public NoteBook() {super();}public NoteBook(String model, double price) {super();this.model = model;this.price = price;}public String getModel() {return model;}public void setModel(String model) {this.model = model;}public double getPrice() {return price;}public void setPrice(double price) {this.price = price;}public NoteBook addNoteBook() {System.out.println("请输入需要配置的笔记本电脑的型号:");String model = TSUtility.readKeyBoard(10, false);System.out.println("请输入需要配置的笔记本电脑的价格:");Double price = TSUtility.readDouble();System.out.println("设备添加成功!");return new NoteBook(model, price);}@Overridepublic String getDescription() {return model + "(" + price + ")";}
}

7.PC类

package domain;import view.TSUtility;//台式电脑
public class PC implements Equipment {//机器型号private String model;//显示器名称private String display;public PC() {super();}public PC(String model, String display) {super();this.model = model;this.display = display;}public String getModel() {return model;}public void setModel(String model) {this.model = model;}public String getDisplay() {return display;}public void setDisplay(String display) {this.display = display;}public PC addPC() {System.out.println("请输入需要配置的台式电脑的型号:");String model = TSUtility.readKeyBoard(10, false);System.out.println("请输入需要配置的台式电脑的显示器名称:");String display = TSUtility.readKeyBoard(10, false);System.out.println("设备添加成功!");return new PC(model, display);}@Overridepublic String getDescription() {return model + "(" + display + ")";}}

8.Printer类

package domain;import view.TSUtility;public class Printer implements Equipment {private String name;private String type;//类型public Printer() {super();}public Printer(String name, String type) {super();this.name = name;this.type = type;}public String getname() {return name;}public void setname(String name) {this.name = name;}public String gettype() {return type;}public void settype(String type) {this.type = type;}public Printer addPrinter() {System.out.println("请输入需要配置的打印机名称:");String name = TSUtility.readKeyBoard(10, false);System.out.println("请输入需要配置的打印机类型:");String type = TSUtility.readKeyBoard(10, false);System.out.println("设备添加成功!");return new Printer(name, type);}@Overridepublic String getDescription() {return name + "(" + type + ")";}
}

9.Project类

package domain;import java.util.Arrays;public class Project {private int proId;//项目号private String proName;//项目名称private String desName;//项目描述private Programmer[] team;//开发团队private String teamName;//开发团队名称private boolean status;//开发状态(true为开发中,false为未开发中)public Project() {}public Project(int proId, String proName, String desName, Programmer[] team, String teamName, boolean status) {this.proId = proId;this.proName = proName;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 getProName() {return proName;}public void setProName(String proName) {this.proName = proName;}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 "Project{" +"proId=" + proId +", proName='" + proName + '\'' +", desName='" + desName + '\'' +", team=" + Arrays.toString(team) +", teamName='" + teamName + '\'' +", status=" + status +'}';}
}

七、service包

1.NameListService类

package service;import domain.*;
import view.TSUtility;import java.util.ArrayList;public class NameListService {private ArrayList<Employee> employees = new ArrayList<>();//用来装员工的数据集合private int count = 1;//添加员工的id{employees.add(new Employee(count, "马云 ", 22, 3000));employees.add(new Architect(++count, "马化腾", 32, 18000, new NoteBook("联想T4", 6000), 60000, 5000));employees.add(new Programmer(++count, "李彦宏", 23, 7000, new PC("戴尔", "NEC 17寸")));employees.add(new Programmer(++count, "刘强东", 24, 7300, new PC("戴尔", "三星 17寸")));employees.add(new Designer(++count, "雷军 ", 50, 10000, new Printer("激光", "佳能2900"), 5000));employees.add(new Programmer(++count, "任志强", 30, 16800, new PC("华硕", "三星 17寸")));employees.add(new Designer(++count, "柳传志", 45, 35500, new PC("华硕", "三星 17寸"), 8000));employees.add(new Architect(++count, "杨元庆", 35, 6500, new Printer("针式", "爱普生20k"), 15500, 1200));employees.add(new Designer(++count, "史玉柱", 27, 7800, new NoteBook("惠普m6", 5800), 1500));employees.add(new Programmer(++count, "丁磊 ", 26, 6600, new PC("戴尔", "NEC17寸")));employees.add(new Programmer(++count, "张朝阳 ", 35, 7100, new PC("华硕", "三星 17寸")));employees.add(new Designer(++count, "杨致远", 38, 9600, new NoteBook("惠普m6", 5800), 3000));}public ArrayList<Employee> getAllEmployees() {//获取所有员工数据集合return employees;}public Employee getEmployee(int id) throws TeamException {//获取员工信息for (int i = 0; i < employees.size(); i++) {if (employees.get(i).getId() == id) {return employees.get(i);}}throw new TeamException("该员工不存在");}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));}
//
//        for (Employee s:employees){
//            System.out.println(s);
//        }
//
//        Iterator<Employee> iterator=employees.iterator();
//        while (iterator.hasNext()){
//            System.out.println(iterator.next());}public void addEmployee() {//增加员工System.out.println("请输入需要添加的员工职位:");System.out.println("1.无职位");System.out.println("2.程序员");System.out.println("3.设计师");System.out.println("4.架构师");String s = String.valueOf(TSUtility.readMenuSelection());if (s.equals("1")) {//无职位 new Employee(count++,"马云 ",22,3000)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(++count, name, age, salary);employees.add(employee);System.out.println("人员添加成功!");TSUtility.readReturn();} else if (s.equals("2")) {//程序员 new Programmer(count++,"张朝阳 ",35,7100,new PC("华硕","三星 17寸"))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();System.out.println("请为当前程序员配一台好的台式电脑:");PC pc = new PC().addPC();Programmer programmer = new Programmer(++count, name, age, salary, pc);employees.add(programmer);System.out.println("人员添加成功!");TSUtility.readReturn();} else if (s.equals("3")) {//设计师 new Designer(count++,"史玉柱",27,7800,new NoteBook("惠普m6",5800),1500)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();System.out.println("请为当前设计师配一台好的笔记本电脑:");NoteBook noteBook = new NoteBook().addNoteBook();System.out.println("请输入当前设计师的奖金:");Double bonus = TSUtility.readDouble();Designer designer = new Designer(++count, name, age, salary, noteBook, bonus);employees.add(designer);System.out.println("人员添加成功!");TSUtility.readReturn();} else {//架构师 new Architect(count++,"杨元庆",35,6500,new Printer("针式","爱普生20k"),15500,1200)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();System.out.println("请为当前架构师配一台好的打印设备:");Printer printer = new Printer().addPrinter();System.out.println("请输入当前架构师的奖金:");Double bonus = TSUtility.readDouble();System.out.println("请输入当前架构师的股票:");Integer stock = TSUtility.readstock();Architect architect = new Architect(++count, name, age, salary, printer, bonus, stock);employees.add(architect);System.out.println("人员添加成功!");TSUtility.readReturn();}}public void delEmployee(int id) {//删除员工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) {count--;System.out.println("删除成功!");} else {try {throw new TeamException("该员工不存在!");} catch (TeamException e) {e.printStackTrace();}}}public void modifyEmployee(int id) {boolean flag = false;for (int i = 0; i < employees.size(); i++) {Employee e = employees.get(i);if (employees.get(i).getId() == id) {System.out.print("姓名(" + e.getName() + "):");String name = TSUtility.readString(4, e.getName());System.out.print("年龄(" + e.getAge() + "):");int age = Integer.parseInt(TSUtility.readString(2, e.getAge() + ""));System.out.print("工资(" + e.getSalary() + "):");double salary = Double.parseDouble(TSUtility.readString(10, e.getSalary() + ""));e.setName(name);e.setAge(age);e.setSalary(salary);employees.set(i, e);flag = true;}}if (flag) {System.out.println("修改成功!");} else {try {throw new TeamException("该员工不存在!");} catch (TeamException e) {e.printStackTrace();}}}
}

2.ProjectService类

package service;import domain.Programmer;
import domain.Project;
import view.TSUtility;import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;public class ProjectService {public ArrayList<Project> p = new ArrayList<>();private int count = 1;//添加项目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(count++);p1.setProName("小米官网");p1.setDesName("开发完成类似于小米官网的web项目.");p.add(p1);TSUtility.loadSpecialEffects();System.out.println("已添加项目:" + p1.getProName());break;case '2':Project p2 = new Project();p2.setProId(count++);p2.setProName("公益在线商城");p2.setDesName("猫宁Morning公益商城是中国公益性在线电子商城.");p.add(p2);TSUtility.loadSpecialEffects();System.out.println("已添加项目:" + p2.getProName());break;case '3':Project p3 = new Project();p3.setProId(count++);p3.setProName("博客系统");p3.setDesName("Java博客系统,让每一个有故事的人更好的表达想法!");p.add(p3);TSUtility.loadSpecialEffects();System.out.println("已添加项目:" + p3.getProName());break;case '4':Project p4 = new Project();p4.setProId(count++);p4.setProName("在线协作文档编辑系统");p4.setDesName("一个很常用的功能,适合小组内的文档编辑。");p.add(p4);TSUtility.loadSpecialEffects();System.out.println("已添加项目:" + p4.getProName());break;default:System.out.println("项目不存在");break;}}public void dealingPro(Programmer[] team) {System.out.println("当前团队有人员:");for (int i = 0; i < team.length; i++) {System.out.println(team[i]);}System.out.println("请为当前团队取一个团队名字:");String teamName = TSUtility.readKeyBoard(6, false);//随机分配项目Random ra = new Random();int ranNum = ra.nextInt(p.size());Project project = this.p.get(ranNum);if (!project.isStatus()) {project.setTeamName(teamName);project.setTeam(team);project.setStatus(true);p.set(ranNum, project);}}public void addProjectTwo() { //新项目添加Scanner sc = new Scanner(System.in);System.out.println("请输入新项目名称:");String projectName = sc.next();System.out.println("请输入新项目简介:");String desName = sc.next();p.add(new Project(++count, projectName, desName, null, null, false));System.out.println("添加成功");TSUtility.readReturn();}public void showProject() throws InterruptedException { //查看项目当前状态TSUtility.loadSpecialEffects(); // 请稍等加载中if (p.size() == 0) {System.out.println("还没有项目,请先添加");return;}for (int i = 0; i < p.size(); i++) {if (!p.get(i).isStatus()) {System.out.println("项目{项目号='" + p.get(i).getProId() + "'项目名='" + p.get(i).getProName() +"', 项目描述='" + p.get(i).getDesName() + ".',开发团队名称='" + p.get(i).getTeamName() +"',开发状态=" + p.get(i).isStatus() + "}");System.out.println("项目【" + p.get(i).getProName() + "】---> 未被开发!");} else {System.out.println("项目【" + p.get(i).getProName() + "】---> " + "正在被团队" +p.get(i).getTeamName() + " 开发中!");}}}//删除项目public void delProject(int id) {boolean flag = false;for (int i = 0; i < p.size(); i++) {if (p.get(i).getProId() == id) {p.remove(i);for (i = id; i <= p.size(); i++) {p.get(i - 1).setProId(p.get(i - 1).getProId() - 1);}flag = true;}}if (flag) {System.out.println("删除成功!");count--;} else {try {throw new TeamException("该项目不存在!");} catch (TeamException e) {e.printStackTrace();}}}//得到所有项目数据集合public ArrayList<Project> getP() {return p;}
}

3.TeamException类

package service;public class TeamException extends Exception {//自定义团队异常public TeamException() {}public TeamException(String message) {super(message);//打印异常信息}
}

4.TeamService类

package service;import domain.Architect;
import domain.Designer;
import domain.Employee;
import domain.Programmer;public class TeamService {private static int counter = 1;//用于自动生成团队成员的memberIdprivate final int MAX_MEMBER = 5;//团队人数上限private Programmer[] team = new Programmer[MAX_MEMBER];//保存当前团队成员private int total = 0;//团队实际人数public static void show(Programmer[] team){for(Programmer n: team){if( n instanceof  Architect){Architect a = (Architect)n;  //向下转型System.out.print( a.getMemberId() +"/"+ a.getId()+"\t\t");System.out.println(a.getName()+"\t"+ a.getAge()+"\t\t"+a.getSalary()+"\t"+"架构师\t"+a.getBonus()+"\t"+a.getStock());}else if (n instanceof  Designer){Designer d = (Designer)n;System.out.print( d.getMemberId() +"/"+ d.getId()+"\t");System.out.println(d.getName()+"\t"+ d.getAge()+"\t\t"+d.getSalary()+"\t"+"设计师\t"+d.getBonus()+"\t");}else {System.out.print( n.getMemberId() +"/"+ n.getId()+"\t");System.out.println(n.getName()+"\t"+ n.getAge()+"\t\t"+n.getSalary()+"\t"+"程序员\t");}}System.out.println("-------------------------------");}//返回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的员工,并删除while (n < total) {if (team[n].getMemberId() == memberId) {team[n].setStatus(true);break;}n++;}//遍历一遍没找到则说明该成员不存在if (n == total) {throw new TeamException("找不到该成员,无法删除");}//删除成功则后面成员id补到前面去System.out.println("删除成功!");for (int i = n + 1; i < total; i++) {team[i - 1] = team[i];}team[--total] = null;}
}

八、view包

1.TSUtility类

package view;import java.util.Random;
import java.util.Scanner;public class TSUtility {private static Scanner sc = new Scanner(System.in);public static char readMenuSelection() {//阅读菜单选择char c;while (true) {String s = readKeyBoard(1, false);c = s.charAt(0);if (c != '1' && c != '2' && c != '3' && c != '4') {System.out.println("选择错误,请重新输入:");} else {break;}}return c;}public static char readMenuSelectionPro() {//阅读菜单选择项目char c;while (true) {String s = readKeyBoard(1, false);c = s.charAt(0);if (c != '1' && c != '2' && c != '3' && c != '4' && c != '5') {System.out.println("选择错误,请重新输入:");} else {break;}}return c;}public static String readKeyBoard(int limit, boolean blankReturn) {//读取键盘String line = "";while (sc.hasNextLine()) {line = sc.nextLine();if (line.length() == 0) {if (blankReturn) {//空白返回return line;} else {continue;}}if (line.length() < 1 || line.length() > limit) {System.out.println("输入长度(不大于" + limit + ")错误,请重新输入:");continue;}break;}return line;}public static void readReturn() {//读取返回System.out.println("按回车键继续...");readKeyBoard(100, true);}public static int readInt() {//读取整型int n;while (true) {String s = readKeyBoard(2, false);try {n = Integer.parseInt(s);break;} catch (NumberFormatException e) {System.out.println("数字输入错误,请重新输入:");}}return n;}public static int readstock() {//股票int n;while (true) {String s = readKeyBoard(6, false);try {n = Integer.parseInt(s);break;} catch (NumberFormatException e) {System.out.println("数字输入错误,请重新输入:");}}return n;}public static double readDouble() {//读取double型double n;while (true) {String s = readKeyBoard(6, false);try {n = Double.parseDouble(s);break;} catch (NumberFormatException e) {System.out.println("数字输入错误,请重新输入:");}}return n;}public static char readConfirmSelection() {//读取确认选项char c;while (true) {String s = readKeyBoard(1, false).toUpperCase();c = s.charAt(0);if (c == 'Y' || c == 'N') {break;} else {System.out.println("选择错误,请重新输入:");}}return c;}public static String readString(int limit, String defaultValue) {//读取String型String s = readKeyBoard(limit, true);return s.equals("") ? defaultValue : s;}public static void loadSpecialEffects() throws InterruptedException {//显示加载进度System.out.println("请稍等:");for (int i = 1; i <= 100; i++) {System.out.print("加载中:" + i + "%");Thread.sleep(new Random().nextInt(25) + 1);if (i == 100) {Thread.sleep(50);}System.out.print("\r");}}
}

2.LoginView类

package view;import java.util.Scanner;public class LoginView {private String userName = "";private String password = "";public void regist() throws InterruptedException {//注册TSUtility.loadSpecialEffects();System.out.println("------------------注册界面------------------");System.out.println("准备注册:");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("请输入账户名称:");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("1.用户名");System.out.println("2.密码");System.out.println("3.用户名和密码");System.out.println("4.不修改,退出");System.out.println("请选择:");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;}}login();}
}

3.TeamView类

package view;import domain.Employee;
import domain.Programmer;
import service.NameListService;
import service.ProjectService;
import service.TeamException;
import service.TeamService;import java.util.ArrayList;
import java.util.Scanner;import static view.TSUtility.readKeyBoard;public class TeamView extends NameListService {private Scanner sc = new Scanner(System.in);private TeamService teamSvc = new TeamService();private NameListService listSvc = null;private ProjectService projectSer = null;public ArrayList<Programmer[]> team = new ArrayList<>();public TeamView() {}public TeamView(NameListService listSvc,ProjectService projectSer) {this.listSvc = listSvc;this.projectSer=projectSer;}public void enterMainMenu() throws TeamException, InterruptedException {boolean b = true;listAllEmployees();//显示员工成员列表while (b) {System.out.println("1-团队列表 2-添加团队成员 3-删除团队成员 4-退出");System.out.print("请选择(1-4):");char c = TSUtility.readMenuSelection();switch (c) {case '1':getTeam();break;case '2'://显示员工成员列表listAllEmployees();addMember();listAllEmployees();break;case '3':getTeam();//团队列表deleteMember();break;case '4':System.out.print("确认是否退出(Y/N):");char c1 = TSUtility.readConfirmSelection();if (c1 == 'Y') {//在集合中添加一个团队team.add(teamSvc.getTeam());//格式化团队teamSvc.clearTeam();b = false;}break;}}}public void listAllEmployees() throws InterruptedException {System.out.println("\n-----------------开发团队调度软件-------------------\n");ArrayList<Employee> allEmployees = listSvc.getAllEmployees();if (allEmployees.size() == 0) {System.out.println("没有员工信息!");} else {listSvc.showEmployee();}}public void getTeam() {System.out.println("------------------团队成员列表------------------");//获取team中所有程序员构成的数组Programmer[] team = teamSvc.getTeam();if (team.length == 0) {System.out.println("开发团队目前没有成员!");} else {System.out.println("TID/ID\t姓名\t\t年龄\t 工资\t 职位\t 奖金\t 股票");//循环输出团队成员信息for (int i = 0; i < team.length; i++) {System.out.println(" " + team[i].getDetailsForTeam());}}System.out.println("----------------------------------------------");}public void addMember() {System.out.println("-------------添加成员-------------");System.out.println("请输入要添加的员工ID:");int id = TSUtility.readInt();int index = -1;//判断输入的id值是否有意义for (int i = 0; i < listSvc.getAllEmployees().size(); i++) {//获取成员集合中的id,看是否存在该idif (listSvc.getAllEmployees().get(i).getId() == id) {//找到的id值赋值给indexindex = id;break;}}if (index == -1) {System.out.println("此id的开发成员不存在");} else {//用户输入的值减1index--;try {//获取成员集合中的元素信息Employee e = listSvc.getAllEmployees().get(index);//添加teamSvc.addMember(e);System.out.println("添加成功");} catch (TeamException e) {System.out.println("添加失败," + e.getMessage());}}TSUtility.readReturn();}//删除团队成员private void deleteMember() throws TeamException {if (teamSvc.getTeam().length == 0) {System.out.println("当前无任何团队!");} else {System.out.println("-------------删除成员-------------");System.out.println("请输入要删除的员工TID:");String s = sc.next();int memberId = TSUtility.readInt();int index = -1;//判断输入的id值是否有意义for (int i = 0; i < teamSvc.getTeam().length; i++) {if (teamSvc.getTeam()[i].getMemberId() == memberId) {index = memberId;break;}}if (index == -1) {System.out.println("此id的团队成员不存在");} else {System.out.print("确认是否删除(Y/N):");char c = TSUtility.readConfirmSelection();if (c == 'Y') {teamSvc.removeMember(index);System.out.println("删除成功");} else System.out.println("已取消删除");}}TSUtility.readReturn();}//查看团队public void showTeam() {System.out.println("-----------团队列表-----------");if (team.size() == 0) {System.out.println("当前无团队信息");System.out.println("-----------------------------");} else {//循环团队集合for (int i = 0; i < team.size(); i++) {//创建数组,团队集合赋值Programmer[] t = team.get(i);//循环集合中的数组for (int j = 0; j < team.get(i).length; j++) {//输出数组中的成员列表System.out.println(t[j]);}System.out.println("-----------------------------");}}}//删除团队public void deleteTeam() {if (team.size() == 0) {System.out.println("当前无团队信息!");} else {System.out.print("请输入想要删除第几个团队:");int num = TSUtility.readInt();if (num <= 0 || num > team.size()) {System.out.println("输入错误,当前共有" + team.size() + "个团队");} else {//输入的值减1num--;System.out.print("确认是否删除(Y/N):");char c = TSUtility.readConfirmSelection();if (c == 'Y') {//创建数组,集合中的团队赋值Programmer[] t = team.get(num);for (int i = 0; i < team.get(num).length; i++) {//修改数组中成员的状态值t[i].setStatus(true);}team.remove(num);System.out.println("团队删除成功!");System.out.println("该团队是否负责项目(Y/N)");String s = readKeyBoard(1, false).toUpperCase();c = s.charAt(0);if (c == 'Y') {System.out.println("请输入该团队负责第几个项目:");int n = TSUtility.readInt();projectSer.delProject(n);} else {return;}} else System.out.println("已取消删除");}}TSUtility.readReturn();}//开发团队调度管理模块public void developmentTeam() throws TeamException, InterruptedException {boolean b = true;while (b) {System.out.println("-----------团队调度界面-----------");System.out.println("1.添加团队");System.out.println("2.查看团队");System.out.println("3.删除团队");System.out.println("4.退出");System.out.print("请选择(1-4):");char c = TSUtility.readMenuSelection();switch (c) {case '1':enterMainMenu();break;case '2':showTeam();break;case '3':deleteTeam();break;case '4':System.out.println("确认退出?(Y/N):");char c1 = TSUtility.readConfirmSelection();if (c1 == 'Y') {b = false;} else {System.out.println("已取消退出!");break;}break;}}}
}

4.IndexView类

package view;import domain.Programmer;
import service.NameListService;
import service.ProjectService;
import service.TeamException;public class IndexView {private LoginView loginVi = new LoginView();private NameListService nameListSer = new NameListService();private ProjectService projectSer = new ProjectService();private TeamView teamVi = new TeamView(nameListSer,projectSer);public void menu() throws TeamException, InterruptedException {boolean loopFlag = true;System.out.println("-----------欢迎来到项目开发团队分配管理软件-----------");System.out.println("-----------请您先进行登录-----------");TSUtility.readReturn();try {loginVi.login();} catch (InterruptedException e) {e.printStackTrace();}while (loopFlag) {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("请选择:");char 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;while (loopFlagSec) {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("请选择:");char keySec = TSUtility.readMenuSelectionPro();switch (keySec) {case '1':try {nameListSer.addEmployee();} catch (Exception 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 (Exception 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;}}break;case '3':teamVi.developmentTeam();break;case '4':boolean loopFlagThr = true;while (loopFlagThr) {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("请选择:");char keyThr = TSUtility.readMenuSelectionPro();switch (keyThr) {case '1':try {projectSer.addProject();} catch (InterruptedException e) {e.printStackTrace();}break;case '2':if (teamVi.team.size() == 0) {System.out.println("没有团队!");} else {for (Programmer[] pro : teamVi.team) {projectSer.dealingPro(pro);}}if (projectSer.p.size() > teamVi.team.size()) {System.out.println("还有项目没有分配团队!");}if (projectSer.p.size() == teamVi.team.size()) {System.out.println("项目分配成功!");}if (projectSer.p.size() < teamVi.team.size()) {System.out.println("还有团队没有分配项目!");}break;case '3':try {projectSer.showProject();} catch (InterruptedException e) {e.printStackTrace();}break;case '4':System.out.println("请输入需要删除的项目id:");int j = TSUtility.readInt();projectSer.delProject(j);break;case '5':System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlagThr = false;}break;default:System.out.println("输入有误!请重新输入!");break;}}break;case '5':System.out.print("确认是否退出(Y/N):");char yn = TSUtility.readConfirmSelection();if (yn == 'Y') {loopFlag = false;}break;default:break;}}}public static void main(String[] args) throws InterruptedException, TeamException {IndexView i = new IndexView();i.menu();}
}

项目开发团队分配管理软件相关推荐

  1. 项目开发团队分配管理软件总结

    目录 前言 一.项目需求 二.主要思路 三.系统流程 四.代码实现 4.1 登录 4.2 开发人员管理模块 4.3开发团队调度管理模块 4.4开发项目管理模块 4.5 IndexView类的设计 五. ...

  2. Java综合项目----开发团队分配管理软件

    Java综合项目----开发团队分配管理软件 源代码下载地址: 简介 需求说明 系统功能结构 系统流程 用户注册和登录模块 开发人员管理模块 Equipment接口及其实现子类的设计 Employee ...

  3. Java 项目开发团队分配管理软件

    目录 1 系统结构功能 2 系统流程 3 软件设计 3.0 前提 3.1 用户注册登录模块 3.2 开发人员管理模块 在这个模块中,我们需要创建几个实体类 3.3 开发团队调度管理模块 3.3.1 需 ...

  4. 【JAVA】项目开发团队分配管理软件

    目录 前言: 一.系统功能结构 二.系统流程 三.实现思路 四.常见问题 五.具体实现代码 六.全部代码 前言: 模拟实现一个基于文本界面的<项目开发团队分配管理软件> 熟悉Java面向对 ...

  5. java实现、项目开发团队分配管理软件

    目标: 模拟实现一个基于文本界面的<项目开发团队分配管理软件> 熟悉Java面向对象的高级特性,进一步掌握编程技巧和调试技巧 主要涉及以下知识点: 类的继承性和多态性 对象的值传递.接口 ...

  6. 实现一个项目开发团队分配管理软件思路及过程

    做一个项目之前首先要知道做什么?实现什么功能?得到什么效果?然后再理思绪以及怎么做,慢慢来,一口吃不成个胖子,切忌一上来就动手做,简单的代码还好,一旦代码更多更复杂进行到后面就很容易乱成一锅粥,所以我 ...

  7. 项目 开发团队分配管理软件

    一.系统功能结构 二.系统流程 三.实现 以下功能不分先后 3.1账户 3.1.1账户类 3.1.2账户管理类 3.2开发人员 3.2.1架构师类 3.2.2开发人员管理类 3.2.3无职务类 3.2 ...

  8. 【面向对象应用~.~】——项目开发团队分配管理软件

    项目大纲 项目介绍 [项目前提] [项目说明] [项目结构] [项目需求] [项目设计框架] 系统功能设计 用户登录和注册 开发人员管理 开发团队调度管理 开发项目管理 各系统功能合并 合并过程 注意 ...

  9. 实践项目《项目开发团队分配管理软件》

    引言 学习接触java有一段时间了,过了一关又一关,掌握并且应用了许多知识同时也在遗忘,第一次接触包含各个部分内容的对我来说大型的项目.在写博客总结的时候回顾为这个项目敲下第一个字符的时候,觉得我能坚 ...

最新文章

  1. 什么是CNN卷积神经网络的感受野及动画演示
  2. Pytorch多进程最佳实践
  3. iis配置绑定二级域名的问题
  4. Too many fragmentation in LMT?
  5. FPGA相关术语(一)
  6. 01-NLP-02-gensim中文处理案例
  7. 【优化算法】搜索引擎优化算法(BES)【含Matlab源码 1426期】
  8. 靶机渗透练习21-Noob
  9. Spring 实体类依赖注入属性的三种方式
  10. 河北楚纳-防电瓶车进入电梯报警系统
  11. 最珍贵的角落-赞美之泉(音乐河2)
  12. OpenCV—python OCR文本检测
  13. python多叉树遍历_基于Python的多叉树遍历算法
  14. Redis分布式缓存学习总结1(安装)
  15. 一言 源码 android,Android - 一言的简单实现
  16. tftpd32下载项目
  17. linux网卡速率和双工模式的配置
  18. python语音验证码识别_python验证码自动识别
  19. ADB调试工具的使用
  20. Selenium登录淘宝 另类方法跳过淘宝滑块验证

热门文章

  1. 51单片机系列(三)51 单片机游戏设计 —— 双人对战小游戏(石头剪刀布)
  2. SQL 如何去掉字段中千位的逗号(比如set @= '1,320.00' 想得到@= '1320.00' )
  3. 用好故事思维,轻松获得人心
  4. 2022电工(初级)考试试题及答案
  5. 可视化工具VisIt安装使用教程(Windows)
  6. Ubuntu 18.04环境配置系统设置
  7. 在使用计算机时可以用什么键关机,电脑死机按什么键关机重启
  8. linux可变剪切分析,SUPPA2进行可变剪切定量
  9. oracle审计功能有什么用,Oracle审计功能
  10. 利用集群技术实现Web服务器的负载均衡 集群和负载均衡的概念