JAV综合项目——项目开发团队分配管理软件

一、系统功能结构图

二、功能需求分析

该软件实现以下功能:
软件启动时,首先进入登录界面进行注册和登录功能。
当登陆成功后,进入菜单,首先就可以对开发人员账户和密码进行修改。
然后可以对开发人员进行增删改操作
人员添加成功后,根据菜单提示,基于现有的公司成员,组建一个开发团队以开发一个新的项目。 组建过程包括将成员插入到团队中,或从团队中删除某成员,还可以列出团队中现有成员的列表,开发团队成员包括架构师、设计师和程序员。
团队组建成功,则可以进入项目模块,添加项目,分配开发团队进行开发。

三、功能实现代码

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<>();

    //添加员工的id
    private int count = 1;

    //初始化默认值
    {
        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 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());
        if (c.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 (c.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 (c.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) {
            System.out.println("删除成功!");
            count--;
        } else {
            try {
                throw new TeamException("该员工不存在");
            } catch (TeamException e) {
                e.printStackTrace();
            }
        }

    }

    //员工的查看
    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));
        }
    }

    //员工的修改 (目前只修改姓名,年龄,工资即可)
    public void modifyEmployee(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();
            }
        }
    }

}
package com.team.service;

import com.team.domain.Employee;
import com.team.domain.Programmer;
import com.team.domain.Project;
import com.team.view.TSUtility;
import com.team.view.TeamView;

import java.util.ArrayList;
import java.util.Random;

/**
 * @author :卿艾迪
 * @date :Created in 2021/3/26 15:44
 * @description:项目相关模块操作
 * 项目参考:
 * 1.小米官网:开发完成类似于小米官网的web项目
 * 2.公益在线商城:猫宁Morning公益商城是中国公益性在线电子商城,以商城B2C模式运营的公益在线商城。
 * 3.博客系统:Java博客系统,让每一个有故事的人更好的表达想法!使用了轻量级 mvc 框架Blade开发,默认主题使用了漂亮的pinghsu。
 * 4.在线协作文档编辑系统:多人在线协作文档编辑器是一个很常用的功能,适合小组内的文档编辑。
 */
public class ProjectService {
    private ArrayList<Project> pro=new ArrayList<>();
    private int count=1;


    public boolean repead(Project project){
        for (int i = 0;i<pro.size();i++){
            if (project.getProName().equals(pro.get(i).getProName())){
                return true;
            }
        }
        return false;
    }
    //添加项目
    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项目.");
                    if (repead(p1)){
                        System.out.println("项目【"+p1.getProName()+"】已存在,不可重复添加");
                    }else {
                        pro.add(p1);
                        TSUtility.loadSpecialEffects();
                        System.out.println("已添加项目:"+p1.getProName());
                    }
                    break;
                case '2':
                    Project p2 = new Project();
                    p2.setProId(count++);
                    p2.setProName("公益在线商城");
                    p2.setDesName("猫宁Morning公益商城是中国公益性在线电子商城.");
                    if (repead(p2)){
                        System.out.println("项目【"+p2.getProName()+"】已存在,不可重复添加");
                    }else {
                        pro.add(p2);
                        TSUtility.loadSpecialEffects();
                        System.out.println("已添加项目:"+p2.getProName());
                    }
                    break;
                case '3':
                    Project p3 = new Project();
                    p3.setProId(count++);
                    p3.setProName("博客系统");
                    p3.setDesName("Java博客系统,让每一个有故事的人更好的表达想法!");
                    if (repead(p3)){
                        System.out.println("项目【"+p3.getProName()+"】已存在,不可重复添加");
                    }else {
                        pro.add(p3);
                        TSUtility.loadSpecialEffects();
                        System.out.println("已添加项目:"+p3.getProName());
                    }
                    break;
                case '4':
                    Project p4 = new Project();
                    p4.setProId(count++);
                    p4.setProName("在线协作文档编辑系统");
                    p4.setDesName("一个很常用的功能,适合小组内的文档编辑。");
                    if (repead(p4)){
                        System.out.println("项目【"+p4.getProName()+"】已存在,不可重复添加");
                    }else {
                        pro.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(pro.size());
        Project project = this.pro.get(ranNum);
        boolean flag = false;
        for (int i = 0; i < pro.size(); i++) {
            if (team == pro.get(i).getTeam()) {
                flag = true;
                break;
            }
        }
        if (flag){
            System.out.println("团队已经分配项目");
        } else {
            if (project.isStatus()) {
                System.out.println("项目已经被开发");
            } else {
                System.out.println("项目分配成功");
                project.setTeamName(teamName);
                project.setTeam(team);
                project.setStatus(true);
                pro.set(ranNum, project);

            }
        }

    }
    //查看目前项目情况
    public void showPro() throws InterruptedException {
        TSUtility.loadSpecialEffects();
        for (int i = 0; i < pro.size(); i++) {
            System.out.println("已有项目"+pro.get(i).getProId()+"  "+pro.get(i).getProName());
            if (pro.get(i).isStatus()){
                System.out.println(pro.get(i).toString()+"正在被【"+pro.get(i).getTeamName()+"】开发中");
            }else
                System.out.println("项目【"+pro.get(i).getProName()+"】未被开发");
        }
    }
    //删除选择的项目
    public void delPro(int id){
        boolean flag = false;
        for (int i = 0; i < pro.size(); i++) {
            if (pro.get(i).getProId() == id) {
                pro.remove(i);
                for (i = id; i <= pro.size(); i++) {
                    pro.get(i - 1).setProId(pro.get(i - 1).getProId() - 1);
                }
                flag = true;
            }
        }
        if (flag) {
            System.out.println("删除成功!");
            count--;
        } else {
            try {
                throw new TeamException();
            } catch (TeamException e) {
                System.out.println("该项目不存在");
            }
        }
    }
    //得到所有项目数据集合
    public ArrayList<Project> getAllPro() {
        return pro;
    }


}
package com.team.service;

import com.team.domain.Architect;
import com.team.domain.Designer;
import com.team.domain.Employee;
import com.team.domain.Programmer;

import java.util.ArrayList;


public class TeamService {
    //用于自动生成团队成员的memberId
    private static int counter = 1;
    //团队人数上限
    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){
            throw new TeamException("成员已满,无法添加");}
        if (!(e instanceof Programmer)) {
            throw new TeamException("该成员不是开发人员,无法添加");
        }
        Programmer p = (Programmer)e;
        
        if (isExist(p)) {
            throw new TeamException("该员工已在本团队中");
        }
        if(!p.getStatus()) {
        	throw new TeamException("该员工已是某团队成员");
        }

        
        int numOfArch = 0, numOfDsgn = 0, numOfPrg = 0;
        for (int i = 0; i < total; i++) {
            if (team[i] instanceof Architect) {numOfArch++;}
            else if (team[i] instanceof Designer){ numOfDsgn++;}
            else if (team[i] instanceof Programmer){ numOfPrg++;}
        }

        if (p instanceof Architect) {
            if (numOfArch >= 1)
            {throw new TeamException("团队中至多只能有一名架构师");}
        } else if (p instanceof Designer) {
            if (numOfDsgn >= 2)
            {throw new TeamException("团队中至多只能有两名设计师");}
        } else if (p instanceof Programmer) {
            if (numOfPrg >= 3)
            {throw new TeamException("团队中至多只能有三名程序员");}
        }
        //添加到数组
        p.setStatus(false);
        p.setMemberId(counter++);
        team[total++] = p;
    }

    private boolean isExist(Programmer p) {
        for (int i = 0; i < total; i++) {
            if (team[i].getId() == p.getId()) return true;
        }

        return false;
    }
    //删除指定memberId的程序员
    public void removeMember(int memberId) throws TeamException {
        int n = 0;
        //找到指定memberId的员工,并删除
        for (; n < total; n++) {
            if (team[n].getMemberId() == memberId) {
                team[n].setStatus(true);
                break;
            }
        }
        //如果遍历一遍,都找不到,则报异常
        if (n == total)
            throw new TeamException("找不到该成员,无法删除");
        //后面的元素覆盖前面的元素
        for (int i = n + 1; i < total; i++) {
            team[i - 1] = team[i];
        }
        team[--total] = null;
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值