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

系统功能结构

 需求说明

该软件实现以下功能:

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

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

然后可以对开发人员进行增删改操作 人员添加成功后,根据菜单提示,基于现有的公司成员,组建一个开发团队以开发一个新的项目。

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

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

软件设计结构

com.team.view    模块为主控模块,负责菜单的显示和处理用户操作

com.team.service  模块为实体对象(Employee及其子类如程序员等)的管理模块, NameListService和TeamService类分别用各自的数组来管理公司员工和开发团队成员对象 ProjectService是对项目的操作对象类 domain模块为Employee及其子类等JavaBean类所在的包 

实体类

 

 

 雇员:

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;
    }

    protected String getDetails() {
        return id + "\t" + name + "\t" + age+ "\t\t" +salary;
    }

    @Override
    public String toString() {
        return getDetails();
    }

}

 

 接口:

public interface Equipment {
    String getDescription();
}

PC:


import work12.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);

    }
    @Override
    public String getDescription() {
        return model + "(" + display + ")";
    }
}

项目开发人员管理

在NameListService类中完成功能操作

实现员工的添加(根据职业添加(无,程序员,设计师,架构师))

实现员工的修改(至少修改员工的姓名,年龄,工资)

实现员工的删除(注意员工id需要动态显示,也就是删除后,员工id需要更新)

实现员工的查看 (显示所有数据)


import work12.domain.*;
import work12.view.TSUtility;

import java.util.ArrayList;

public class NameListService {
    private ArrayList<Employee> employees = new ArrayList<>();//存人员信息
    private int count = 1;//记录序号
    static NameListService listSvc = new NameListService();
    //初始化人员名单
    {
        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 void NameListMenu() {
        while (true) {
            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 c = TSUtility.readMenuSelectionPro();
            switch (c) {
                case '1':
                    addEmployee();
                    break;
                case '2':
                    getAllEmployees2();
                    break;
                case '3':
                    setEmployees();
                    break;
                case '4':
                    deleteEmployee();
                    break;
                case '5':
                    System.out.print("确认是否退出(Y/N):");
                    char b = TSUtility.readConfirmSelection();
                    if (b == 'Y') {
                        return;
                    }
            }
        }
    }

    //得到所有员工
    public ArrayList<Employee> getAllEmployees() {

        return employees;
    }

    //遍历所有员工
    public void getAllEmployees2() {
        System.out.println("ID\t姓名\t\t年龄\t\t工资\t\t 职位\t状态\t\t奖金\t\t股票\t\t领用设备");
        for (int i = 0; i < employees.size(); i++) {
            System.out.println(employees.get(i));
        }
    }


    //查询指定员工
    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 addEmployee() {
        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 a = TSUtility.readMenuSelectionPro();
        String name;
        int age;
        double bonus;
        switch (a) {
            case '1':
                System.out.print("请输入姓名:");
                name = TSUtility.readKeyBoard(4, false);
                System.out.print("请输入年龄:");
                age = TSUtility.readInt();
                System.out.print("请输入工资:");
                double salary = TSUtility.readDouble();
                employees.add(new Employee(++count, name, age, salary));
                System.out.println("添加成功!!!");
                break;
            case '2':
                System.out.print("请输入姓名:");
                name = TSUtility.readKeyBoard(4, false);
                System.out.print("请输入年龄:");
                age = TSUtility.readInt();
                System.out.print("请输入工资:");
                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("人员添加成功!");
                break;
            case '3':
                System.out.print("请输入姓名:");
                name = TSUtility.readKeyBoard(4, false);
                System.out.print("请输入年龄:");
                age = TSUtility.readInt();
                System.out.print("请输入工资:");
                salary = TSUtility.readDouble();
                System.out.println("请为当前设计师配一台好的笔记本电脑:");
                NoteBook noteBook = new NoteBook().addNoteBook();
                System.out.println("请输入当前设计师的奖金:");
                bonus = TSUtility.readDouble();
                Designer designer = new Designer(++count, name, age, salary, noteBook, bonus);
                employees.add(designer);
                System.out.println("人员添加成功!");
                break;
            case '4':
                System.out.print("请输入名字:");
                name = TSUtility.readKeyBoard(4, false);
                System.out.print("请输入年龄:");
                age = TSUtility.readInt();
                System.out.print("请输入工资:");
                salary = TSUtility.readDouble();
                System.out.println("请为当前架构师配一台好的打印设备:");
                Printer printer = new Printer().addPrinter();
                System.out.println("请输入当前架构师的奖金:");
                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("人员添加成功!");
                break;
            case '5':
                System.out.println("是否确认退出(输入Y/N):");
                char b = TSUtility.readConfirmSelection();
                if (b == 'Y') {
                    return;
                }
        }
    }

    //删除员工
    public void deleteEmployee() {
        System.out.print("请输入需要删除的员工id:");
        int id = TSUtility.readInt();
        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("删除成功!");
            count--;
        } else {
            try {
                throw new TeamException("该员工不存在");
            } catch (TeamException e) {
                e.printStackTrace();
            }
        }
    }


    //修改员工信息(只能修改名字、年龄、工资)
    public void setEmployees() {
        System.out.print("请输入需要修改的ID:");
        int a = TSUtility.readInt();
        if (a > count) {
            try {
                throw new TeamException("该员工不存在!!!");
            } catch (TeamException e) {
                e.printStackTrace();
            }
            return;
        }
        Employee b = employees.get(a - 1);
        System.out.print("请输入新的姓名(" + employees.get(a - 1).getName() + "):");
        String name = TSUtility.readString(4, b.getName());
        System.out.print("请输入新的年龄(" + b.getAge() + "):");
        int age = Integer.parseInt(TSUtility.readString(2, b.getAge() + ""));
        System.out.print("请输入新的工资(" + b.getSalary() + "):");
        double salary = Double.parseDouble(TSUtility.readString(10, b.getSalary() + ""));
        b.setName(name);
        b.setAge(age);
        b.setSalary(salary);
        employees.set(a - 1, b);
        System.out.println("修改成功!!!");
    }

    //开发人员的查看视图(供本类NameListMenu()方法以及TeamView类addTeamView()调用)
    public void getAllEmployeesView() {
        ArrayList<Employee> allEmployees = listSvc.getAllEmployees();
        System.out.println("ID\t姓名\t\t年龄\t\t工资\t\t 职位\t状态\t\t奖金\t\t股票\t\t领用设备");
        for (Employee emp : allEmployees) {
            if (emp instanceof Architect) {
                Architect a = (Architect) emp;
                System.out.println(a + "\t架构师\t" + a.isStatus() + "\t" + a.getBonus() + "\t" + a.getStock() + "\t"
                        + a.getEquipment().getDescription());
            } else if (emp instanceof Designer) {
                Designer d = (Designer) emp;
                System.out.println(d + "\t设计师\t" + d.isStatus() + "\t" + d.getBonus() + "\t\t\t"
                        + d.getEquipment().getDescription());
            } else if (emp instanceof Programmer) {
                Programmer p = (Programmer) emp;
                System.out.println(p + "\t程序员\t" + p.isStatus() + "\t\t\t\t\t" + p.getEquipment().getDescription());
            } else {
                System.out.println(emp);
            }
        }
    }

//    //测试
//    public static void main(String[] args) {
//        NameListService sc= new NameListService();
//        sc.NameListMenu();
//    }
}

项目团队管理

 

 


import work12.domain.Architect;
import work12.domain.Designer;
import work12.domain.Employee;
import work12.domain.Programmer;

public class TeamService {
    private static int counter = 1;//用于自动生成团队成员的memberId
    private final int MAX_MEMBER = 5;//限制开发团队人数上限
    private Programmer[] team = new Programmer[MAX_MEMBER];//保存当前团队成员
    private int total = 0;//记录开发团队实际人数

    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){//当total==5时,团队里已经添加了5个(total++是先添加再++)
            throw new TeamException("团队成员已满,无法添加!");
        }
        if (!(e instanceof Programmer)){
            throw new TeamException("该成员不是开发人员,无法添加!");
        }

        Programmer p=(Programmer) e;//向下转型,以便于调用子类的成员变量

        if (isExist(p)){
            throw new TeamException("该成员已在本团队中");//抛出,抛出信息被调用者接收
        }

        if(!p.isStatus()) {
            throw new TeamException("该员工已是某团队成员");
        }


        //添加团队
        int numOfA=0,numOfDe=0,numOfPro=0;
        for (int i = 0; i < total; i++) {//先检查数组team里 相应员工的数量
            if (team[i] instanceof Architect){numOfA++;}
            else if (team[i] instanceof Designer){numOfDe++;}
            else if (team[i] instanceof Programmer){numOfPro++;}
        }
        if (p instanceof Architect){
            if (numOfA>=1){//因为num是从0开始,所以等于1就相当于有了两名
                throw new TeamException("团队中至多只能有一名架构师");}}
        else if (p instanceof Designer){
            if (numOfDe>=2){
                throw new TeamException("团队中至多只能有两名设计师");}}
        else if (p instanceof Programmer){
            if (numOfPro>=3){
                throw new TeamException("团队中至多只能有三名程序员");}}
        //添加到数组  注意!!!! 需要把team数组 放到判断 抛出异常之后,不然会先添加数据,再执行异常(异常只起到了提示作用,没有防止数据继续添加到团队中)
        p.setStatus(false);
        p.setMemberID(counter++);//调用子类的成员变量
        team[total++]=p;
    }

    //判断该成员是否已经在团队里
    public 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;
    }
}

 


import work12.domain.Employee;
import work12.domain.Programmer;
import work12.service.NameListService;
import work12.service.TeamException;
import work12.service.TeamService;

import java.util.ArrayList;


public class TeamView {
    private NameListService lis = new NameListService();
    private TeamService teamSvc = new TeamService();
    private ArrayList<Programmer[]> team = new ArrayList<>();
    private static IndexView I = new IndexView();


    //主菜单
    public void enterMainMenu() {

        boolean loopFlag = true;
        char key = 0;
        do {
            if (key != '1') {
                listAllEmployees();
            }
            System.out.println("1-团队成员列表  2-添加团队成员  3-删除团队成员 4-退出   请选择(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.print("确认是否退出(Y/N):");
                    char yn = TSUtility.readConfirmSelection();
                    if (yn == 'Y') {
                        if (teamSvc.getTeam().length == 0) {
                            loopFlag = false;
                        } else {
                            team.add(teamSvc.getTeam());//获取存入team中所有程序员构成的数组,每调用一次,就在集合team里存入了一个团队
                            teamSvc.clearTeam();//每次退出都会初始化当前团队的成员数组 teamSvc,以便于下一次加入新的团队
                            loopFlag = false;
                        }
                    }
                    break;
                default:
                    break;
            }
        } while (loopFlag);
    }//分别调用了增删改查功能

    //显示所有的员工成员
    public void listAllEmployees() {
        System.out.println("~~~~~~~~~~~~~~欢迎来到团队调度软件~~~~~~~~~~~~~~~");
        ArrayList<Employee> emps = lis.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领用设备");
        }
        for (int i = 0; i < emps.size(); i++) {
            System.out.println(" " + emps.get(i));
        }
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    }

    //显示开发团队成员列表
    public void listTeam() {
        System.out.println("~~~~~~~~~~~~~~~~团队成员列表~~~~~~~~~~~~~~~~");
        Programmer[] team = teamSvc.getTeam();//获取team中所有程序员构成的数组
        if (team.length == 0) {
            System.out.println("开发团队目前没有成员!");
        } else {
            System.out.println("TID/ID\t姓名\t\t工资\t\t职位\t\t奖金\t\t股票");
        }
        for (int i = 0; i < team.length; i++) {//打印输出
            System.out.println(" " + team[i].getDetailsForTeam());
        }
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    }

    // 添加成员到团队
    private void addMember() {
        System.out.println("---------------------添加成员---------------------");
        System.out.print("请输入要添加的员工ID:");
        int id = TSUtility.readInt();

        try {
            Employee e = lis.getEmployee(id);
            teamSvc.addMember(e);//添加成员到团队
            System.out.println("添加成功");
        } catch (TeamException e) {
            System.out.println("添加失败,原因:" + e.getMessage());
        }
        // 按回车键继续...
        TSUtility.readReturn();
    }

    // 从团队中删除指定id的成员
    private void deleteMember() {
        System.out.println("---------------------删除成员---------------------");
        System.out.print("请输入要删除员工的TID:");
        int id = TSUtility.readInt();
        System.out.print("确认是否删除(Y/N):");
        char yn = TSUtility.readConfirmSelection();
        if (yn == 'N')
            return;

        try {
            teamSvc.removeMember(id);//改变员工的状态,表示将其移除团队
            System.out.println("删除成功");
        } catch (TeamException e) {
            System.out.println("删除失败,原因:" + e.getMessage());
        }
        // 按回车键继续...
        TSUtility.readReturn();
    }

    // 加入并得到更多的团队
    public ArrayList<Programmer[]> getManyTeam(NameListService nameListSer) {
        boolean flag = true;
        char key = 0;
        lis = nameListSer;//将传入的对象,赋值给lis ,使得lis可以用到参数对象里的 数据
        do {
            System.out.println("※※※※※※※※※※※");
            System.out.println("※   团队调度界面   ※");
            System.out.println("※※※※※※※※※※※");
            System.out.print("1-添加团队 2-查看团队 3-删除团队 4-退出   请选择(1-4):");
            key = TSUtility.readMenuSelection();
            System.out.println();
            switch (key) {
                case '1':
                    enterMainMenu();
                    break;
                case '2':
                    System.out.println("~~~~~~~~~~~~~~~~~~团队列表~~~~~~~~~~~~~~~~~~~~~~");
                    for (Programmer[] team : team) {
                        for (int i = 0; i < team.length; i++) {
                            System.out.println(team[i]);
                        }
                        /*for (int i = 0; i < team.length; i++) {
                            System.out.println(team[i]);
                        }*/
                        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
                    }
                    break;
                case '3':
                    System.out.println("请输入想要删除第几个团队");
                    int num = TSUtility.readInt();
                    if (num <= team.size()) {
                        System.out.print("确认是否删除(Y/N):");
                        char de = TSUtility.readConfirmSelection();
                        if (de == 'Y') {
                            team.remove(num - 1);
                        } else {
                            System.out.println("请确认!");
                        }
                    } else {
                        System.out.println("没有该团队,请正常输入!" + "目前团队只有" + team.size() + "个");
                    }
                    break;
                case '4':
                    System.out.print("确认是否退出(Y/N):");
                    char yn = TSUtility.readConfirmSelection();
                    if (yn == 'Y') {
                        flag = false;
                    }
                    break;
                default:
                    break;
            }
        } while (flag);
        return team;
    }//调用了主菜单的功能
}

开发项目管理

public class Project {
    private int proId;//项目号
    private String projectName;//项目名称
    private String desName;//项目描述
    private Programmer[] team;//开发团队
    private String teamName;//开发团队名称
    private boolean status=false;//true为开发中,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 getStatus() {
        return status;
    }
    public void setStatus(boolean status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return "项目{" +
                "项目号='" + proId + '\'' +
                "项目名='" + projectName + '\'' +
                ", 项目描述='" + desName + '\'' +
                ", 开发团队名称='" + teamName + '\'' +
                ", 开发状态=" + status +
                '}' + "\n";
    }
}

 


import work12.domain.Programmer;
import work12.domain.Project;
import work12.view.TSUtility;
import java.util.ArrayList;
import java.util.Random;



public class ProjectService {
    //用来存项目的集合
    private ArrayList<Project> pro = new ArrayList<>();
    //添加项目的标号
    private int count = 1;


    public void projectMenu() throws InterruptedException {
        while (true) {
            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.print("请选择:");
            switch (TSUtility.readMenuSelectionPro()) {
                case '1':
                    addProjectView();
                    break;
                case '2':
                    dealingProView();
                    break;
                case '3':
                    showPro();
                    break;
                case '4':
                    delProView();
                    break;
                case '5':
                    System.out.print("确认是否退出(Y/N):");
                    if (TSUtility.readConfirmSelection() == 'Y') {
                        return;
                    }
                    break;
            }
        }
    }

    private void dealingProView() {

    }


    //项目的添加交互界面
    public void addProjectView() 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.setProjectName("小米官网");
                p1.setDesName("开发完成类似于小米官网的web项目.");
                pro.add(p1);
                TSUtility.loadSpecialEffects();
                System.out.println("已添加项目:" + p1.getProjectName());
                break;
            case '2':
                Project p2 = new Project();
                p2.setProId(count++);
                p2.setProjectName("公益在线商城");
                p2.setDesName("猫宁Morning公益商城是中国公益性在线电子商城.");
                pro.add(p2);
                TSUtility.loadSpecialEffects();
                System.out.println("已添加项目:"+p2.getProjectName());
                break;
            case '3':
                Project p3 = new Project();
                p3.setProId(count++);
                p3.setProjectName("博客系统");
                p3.setDesName("Java博客系统,让每一个有故事的人更好的表达想法!");
                pro.add(p3);
                TSUtility.loadSpecialEffects();
                System.out.println("已添加项目:"+p3.getProjectName());
                break;
            case '4':
                Project p4 = new Project();
                p4.setProId(count++);
                p4.setProjectName("在线协作文档编辑系统");
                p4.setDesName("一个很常用的功能,适合小组内的文档编辑。");
                pro.add(p4);
                TSUtility.loadSpecialEffects();
                System.out.println("已添加项目:"+p4.getProjectName());
                break;
            default:
                System.out.println("项目不存在");
                break;
        }
    }

    //项目分配开发团队交互界面
    public void dealingProView(Programmer[] team) {
        if (pro.size()==0){
            System.out.println("请先添加项目");
        }
        else {
            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(pro.size());
            Project project = this.pro.get(ranNum);
            while (project.getStatus()){ //使用while循环,判断如果项目已经开发,重新读取
                ranNum= ra.nextInt(pro.size());//重新获取随机数
                project=this.pro.get(ranNum);//集合重新取出随机项目
            }
            project.setTeamName(teamName);
            project.setTeam(team);
            project.setStatus(true);
            pro.set(ranNum, project);
        }
    }

    //项目的查看
    private void showPro() {
        for (int i = 0; i < pro.size(); i++) {
            System.out.println(pro.get(i));
        }
        for (Project p : pro) {
            if (p.getStatus()) {
                System.out.println("项目【" + p.getProjectName() + "】---->正在被团队【" + p.getTeamName() + "】开发中!");
            } else {
                System.out.println(p + "\n项目【" + p.getProjectName() + "】---->未被开发!");
            }
        }
    }

    //项目的删除交互界面
    private void delProView() {
        boolean flag = false;
        System.out.print("请输入需要删除的项目id:");
        int id = TSUtility.readInt();
        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 ArrayList<Project> getAllPro() {
        return pro;
    }
}


 自定义异常:


public class TeamException extends Exception {
    public TeamException() {
    }

    public TeamException(String message) {
        super(message);
    }
}

注册登录修改:


public class LoginView {
    private String userName = "";
    private String password = "";

    //用户登录注册页面
    public void menuLV() throws InterruptedException {
        System.out.println("                          ");
        System.out.println("--------用户登录页面--------");
        System.out.println("                          ");
        System.out.println("       1.注册账户          ");
        System.out.println("       2.登    录         ");
        System.out.println("       3.退出软件          ");
        System.out.println("                          ");
        System.out.println("    请选择你要执行的操作:    ");
        char line = TSUtility.readMenuSelection();
        switch (line) {
            case '1':
                register();
            case '2':
                login();
                break;
        }
    }

    //注册
    public void register() throws InterruptedException {
        TSUtility.loadSpecialEffects();
        System.out.println("--------注册界面--------");
        Scanner input = 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("请输入用户名:");
            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("未检测到账号,请先注册!");
                register();
            }
            //已有账号正常登录
            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 modify() 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.<不修改,退出>");
            Scanner sc = new Scanner(System.in);
            String input = sc.next();
            if (input.equals("1")) {
                System.out.println("请输入新的用户名:");
                String userName = TSUtility.readKeyBoard(4, false);
                this.userName = userName;
                TSUtility.loadSpecialEffects();
                System.out.println("修改成功!");
            } else if (input.equals("2")) {
                System.out.println("请输入新的用户密码:");
                String password = TSUtility.readKeyBoard(8, false);
                this.password = password;
                TSUtility.loadSpecialEffects();
                System.out.println("修改成功!");
            } else if (input.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;
                TSUtility.loadSpecialEffects();
                System.out.println("修改成功!");
            } else if (input.equals("4")) {
                System.out.println("正在退出");
                TSUtility.loadSpecialEffects();
                flag = false;
                System.out.println("退出成功!");
            } else {
                System.out.println("输入错误,请重新输入:1或2或3或4");
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        LoginView l=new LoginView();
        l.menuLV();
    }
}

主菜单:

将功能给串接起来,注意该软件仅仅需要完成需求说明的相关要求即可。


public class IndexView {
    private static LoginView lv = new LoginView();
    private static NameListService nlv = new NameListService();
    private static TeamView tv = new TeamView();
    private static ProjectService pv = new ProjectService();
    /*
      颜色特效
     */
    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_BLUE = "\u001B[34m";



    //软件主菜单
    private void MainMenu() throws TeamException, InterruptedException {
        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 {
            System.out.println(ANSI_BLUE);
            lv.menuLV();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        while (true) {
            System.out.println(ANSI_RESET + ANSI_BLUE);
            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);
            switch (TSUtility.readMenuSelectionPro()) {
                case '1':
                        lv.modify();
                    break;
                case '2':
                    nlv.NameListMenu();
                    break;
                case '3':
                    tv.enterMainMenu();
                    break;
                case '4':
                    pv.projectMenu();
                    break;
                case '5':
                    System.out.print("确认是否退出(Y/N):");
                    if (TSUtility.readConfirmSelection() == 'Y') {
                        System.exit(0);
                    }
                    break;
            }
        }
    }
    public static void main(String[] args) throws InterruptedException, TeamException {
        IndexView iv = new IndexView();
        iv.MainMenu();
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值