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

Posted 代码小k

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实践项目《项目开发团队分配管理软件》相关的知识,希望对你有一定的参考价值。

引言

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

需求

该软件实现以下功能:

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

思路

系统功能结构如图所示:

系统流程图如下:

软件设计包含如下三个模块

模块功能如下:
1team.view 模块为主控模块,负责菜单的显示和处理用户操作

2team.service 模块为实体对象(Employee及其子类如程序员等)的管理模块, NameListService和TeamService类分别用各自的数组来管理公司员工和开发团队成员对象

3ProjectService是对项目的操作对象类

4domain模块为Employee及其子类等JavaBean类所在的包

心得
拆分为用户登陆注册,开发人员管理,开发团队调度管理,开发项目管理这四个功能块分开进行设计,并进行bug测试,最后进行汇总调试。

具体实现

domain包下

雇员类Employee


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 getDetails()
        return id+"\\t"+name+"\\t"+age+"\\t"+salary;

    

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


Employee子类:程序员Programmer

public class Programmer extends Employee
    private int memberId;
    boolean status=true;
    Equipment equipment;
    public Programmer();

    public Programmer(int id, String name, int age, double salary, Equipment equipment) 
//    super(id, name, age, salary);
        super(id,name,age,salary);
        this.equipment=equipment;
    

    public int getMemberId() 
        return memberId;
    

    public void setMemberId(int memberId) 
        this.memberId = memberId;
    

    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;
    
    protected String getMemberdetails()
        return getMemberId()+getDetails();
    
    public String getDetailsForTeam()
        return getMemberdetails()+"\\t程序员";
    

    @Override
    public String toString() 
        return getDetails()+"\\t程序员\\t"+status+"\\t\\t\\t\\t"+equipment.getDescription();
    


Programmer子类:设计师类Desiger:

public class Designer extends Programmer
    double bouns; //奖金
    public Designer()

    public Designer(int id, String name, int age, double salary, Equipment equipment, double bouns) 
        super( id, name, age, salary, equipment );
        this.bouns = bouns;
    

    public double getBouns() 
        return bouns;
    

    public void setBouns(double bouns) 
        this.bouns = bouns;
    
    public String getDetailsForTeam()
        return getMemberdetails()+"\\t设计师\\t"+getBouns();
    

    @Override
    public String toString() 
        return getDetails()+"\\t设计师\\t"+getStatus()+"\\t"+
                getBouns()+"\\t\\t\\t"+getEquipment().getDescription();
    

Desiger子类:架构师类Architect:

public class Architect extends Designer
    private int stock;//奖励股票
    public Architect()
    public Architect(int id, String name, int age, double salary, Equipment equipment, double bouns, int stock) 
        super( id, name, age, salary, equipment, bouns );
        this.stock = stock;
    

    public int getStock() 
        return stock;
    

    public void setStock(int stock) 
        this.stock = stock;
    

    @Override
    public String getDetailsForTeam() 
        return getMemberdetails()+"\\t架构师\\t"+getStatus()+"\\t"
                +getBouns()+"\\t"+getStock()+"\\t"+getEquipment().getDescription();
    

    @Override
    public String toString() 
        return getDetails()+"\\t架构师\\t"+getStatus()+"\\t"+
                getBouns()+"\\t"+getStock()+"\\t"+getEquipment().getDescription();
    

Equipment接口:


public interface Equipment 
    String getDescription();


Equipment子类:PC(台式电脑)


import view.TSUtility;

public class PC implements Equipment
    //model 表示机器的型号
    private String model;
    //display 表示显示器名称
    private String display;

    public PC()
        super();
    


    public PC(String model, String display) 
        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+")";
    

Equipment子类:NoteBook(笔记本电脑)


import view.TSUtility;

public class NoteBook implements Equipment
    private String model;
    private double price;
    public NoteBook()
        super();
    

    public NoteBook(String model, double price) 
        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);

    

    @Override
    public String getDescription() 
        return model + "(" + price + ")";
    

Equipment子类:Printer(打印机)


import view.TSUtility;

public class Printer implements Equipment
    private String name;
    private String type;
    public Printer()
        super();
    

    public Printer(String name, String type) 
        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);
    

    @Override
    public String getDescription() 
        return name+"("+type+")";
    

service包下

自定义异常类 TeamException

public class TeamException extends Exception
    public TeamException() 
    

    public TeamException(String message) 
        super(message);
    


开发人员管理模块:NameListService

import domain.*;
import view.TSUtility;

import java.util.ArrayList;

public class NameListService 
   //实现员工的添加(根据职业添加(无,程序员,设计师,架构师))
   //c创建一个装员工的数据集合
   private static ArrayList<Employee> employees = new ArrayList<>();
   //添加员工id
   private int count = 1;

   public NameListService() 
       super();
   

   public NameListService(ArrayList<Employee> employees, int count) 
       this.employees = employees;
       this.count = count;
   

   public ArrayList<Employee> getEmployees() 
       return employees;
   

   public void setEmployees(ArrayList<Employee> employees) 
       this.employees = employees;
   

   public int getCount() 
       return count;
   

   public void setCount(int count) 
       this.count = count;
   

   //初始化默认值(用户数据互通,避免代码块数据和自己添加数据无法继续进行使用的问题)
   
       if (employees.isEmpty()) 
           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 a = String.valueOf( TSUtility.readMenuSelection() );

       if (a.equals( "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( ++count, name, age, salary );
           employees.add( employee );
           System.out.println( "人员添加成功!" );
           TSUtility.readReturn();

        else if (a.equals( "2" )) //程序员
           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 );
           TSUtility.readReturn();

        else if (a.equals( "3" )) //设计师
           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 //架构师
           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 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.println( "姓名(" + emp.getName() + ")如果不用修改请按Enter键" );
               String name = TSUtility.readString( 4, emp.getName() );
               System.out.println( "年龄(" + emp.getAge() + ")如果不用修改请按Enter键" );
               int age = Integer.parseInt( TSUtility.readString( 2, emp.getAge() + "" ) );
               System.out.println( "工资(" + emp.getSalary() + ")如果不用修改请按Enter键" );
               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) 
               System.out.println( e.getMessage() );
           
       
   

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


   public void delEmployee(int id) throws TeamException 
       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++) 
   //个人理解是不停的让后面的序号-1覆盖前面的从而实现删除元素后前后序号排序正常。
                   employees.get( i - 1 ).setId( employees.get( i - 1 ).getId() - 1 );
               
               flag = true;
           
       

       if (flag) 
           System.out.println( "删除成功!" );
           count--;
        else 
           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 ) );
       
   




开发人员调度管理模块:TeamService


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

//管理开发团队成员
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() 
  

  public TeamService(Programmer[] team, int total, int counter) 
      this.team = team;
      this.total = total;
      this.counter = counter;
  

  //返回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)) 
          //instanceof
          //instanceof是Java的一个保留关键字,左边是对象,右边是类,
          // 返回类型是Boolean类型。它的具体作用是测试左边的对象是否是右边类或者该类的子类创建的实例对象,
          // 是,则返回true,否则返回false。
          throw new TeamException( "该成员不是开发人员,无法添加" );
      
      Programmer p = (Programmer) e;

      if (isExit( 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( "团队中至多只能有一名架构师" );
          
          if (numOfDsgn > 2) 
              throw new TeamException( "团队中至多只能有两名设计师" );
          
          if (numOfPrg > 3) 
              throw new TeamException( "团队中至多只能有三名程序员" );
          
      
      //添加到数组
      p.setStatus( false );
      p.setMemberId( counter++ );
      team[total++] = p;
  

  //判断这个成员在团队中是否存在
  private boolean isExit(Programmer p) 
      for (int i = 0; i < total; i++) 
          if (team[i].getId() == p.getId()) return true;
      
      return false;
  

  //删除指定的团队成员
  public void removeMember(int menmberId) throws TeamException 
      int n = 0;
      //找到指定员工进行删除
      for (; n < total; n++) 
          if (team[n].getId() == menmberId) 
              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;

      //编写改变后的id
      int i = 1;
      for (int j = 0; j < total; j++) 
          team[j].setMemberId( i++ );
      

  




开发项目管理模块:ProjectService


import domain.Programmer;
import domain.Project;
import 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 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();
            int c1 = 1;
            int c2 = 2;
            int c3 = 3;
            int c4 = 4;

        switch (c)
            case '1':
                Project p1 = new Project();
                p1.setProId( count++ );
                p1.setProName( "小米官网" );
                p1.setDesName( "开发类似小米官网的web项目" );

                //如何判断已经存在一个重名的或者添加的相同的呢?
                if (c1==1)
                    pro.add( p1 );
                    TSUtility.loadSpecialEffects();
                    System.out.println("已经添加的项目"+p1.getProName());
                    c1++;
                else 
                    System.out.println("项目已经被添加,请添加其他项目");
                
                break;
            case'2':
                Project p2 =new Project();
                p2.setProId( count++ );
                p2.setProName( "公益在线商城" );
                p2.setDesName( "猫宁Morning公益商城是中国公益性在线电子商城." );
                if (c2==2)
                    pro.add( p2 );
                    TSUtility.loadSpecialEffects();
                    System.out.println("已经添加的项目"+p2.getProName());
                    c2++;
                else 
                    System.out.println("项目已经被添加,请添加其他项目");
                
                break;
            case'3':
                Project p3 = new Project();
                p3.setProId( count++ );
                p3.setProName( "博客系统" );
                p3.setDesName( "Java博客系统,让每一个有故事的人更好的表达想法!" );
                if (c3==1)
                    pro.add( p3 );
                    TSUtility.loadSpecialEffects();
                    System.out.println("已经添加的项目"+p3.getProName());
                    c3++;
                else 
                    System.out.println("项目已经被添加,请添加其他项目");
                
                break;
            case'4':
                Project p4 = new Project();
                p4.setProId( count++ );
                p4.setProName( "在线协作文档编辑系统" );
                p4.setDesName( "一个很常用的功能,适合小组内的文档编辑。" );
                if (c4==1)
                    pro.add( p4 );
                    TSUtility.loadSpecialEffects();
                    System.out.println("已经添加的项目"+p4.getProName());
                    c4++;
                else 
                    System.out.println("项目已经被添加,请添加其他项目");
                
                break;
            default:
                System.out.println("该项目不存在");
                break;
        
    

    //项目分配团队开发
    public void dealingPro(Programmer[]team)
        //判断是否存在团队
        if (pro==null)
            System.out.println("当前无项目,请先添加项目");
            return;
        
        //给项目分配团队
        System.out.println("当前团队人员有:");
        for (int i = 0; i < team.length; i++) 
            System.out.println(team[i]);
        
        System.out.println("请为当前团队命名:");
        String teamName = TSUtility.readKeyBoard( 8,false );
        //随机分配项目
        if (team.length!=0)//判断team是否为空
            Random ra = new Random();
            int ranNum = ra.nextInt(pro.size());//该方法的作用是在(0,pro.size]之间娶一个随机值
            Project project = this.pro.get( ranNum );
            if (project!=null)//判断project是否为空值
                project.setTeamName(teamName);
                project.setTeam( team );
                project.setStatus( true );
            
        


    
    //查看项目当前状态
    public void showPro()throws InterruptedException
        if (pro.size()==0)
            TSUtility.loadSpecialEffects();
            System.out.println("当前没有项目,请先添加项目");
        
        for (int i = 0; i < pro.size(); i++) 
            System.out.println(pro.get( i ).toString());
        
    

    //删除所选择的项目
    public void delPro(int id )throws TeamException
        boolean flag = false;
        for (int i = 0; i < pro.size(); i++) 
            if ((pro.get(i).getStatus())!=true) 
                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);//动态ID改变
                    
                    flag = true;
                
             else 
//                throw new TeamException("当前项目正在被开发,无法删除!");
                System.out.println("当前项目正在被开发,无法删除!");
                System.out.println("如果坚持删除请选择1,退出选择2");
                boolean loopflag = true;
                char key = TSUtility.readMenuSelection();
                do 
                    switch (key)
                        case '1':
                            for (int j = 0; j < pro.size(); j++) 
                                if (pro.get( j ).getProId()==id)
                                    pro.remove( j );
                                    for (j  = id ;j<pro.size();j++) 
                                        pro.get( j-1 ).setProId( pro.get( j-1 ).getProId()-1 );
                                    
                                
                            
                            System.out.println("删除成功");
                            count--;
                            loopflag = false;
                            break;
                        case '2':
                            loopflag = false;
                            break;
                        default:
                            System.out.println("输入有误");
                            break;
                    
                while (loopflag);
            
        
        if (flag) 
            System.out.println("删除成功!");
            count--;
         else 
            try 
                throw new TeamException("该项目不存在!");
             catch (TeamException e) 
                System.out.println( e.getMessage() );
            
        

    

    //得到所有项目数据集合
    public ArrayList<Project>getALLpro()
        for (int i = 0; i < pro.size(); i++) 
            System.out.println(pro.get( i ));
        
        return pro;
    


view包下

用户注册和登录模块 Loginview

import java.util.Scanner;

//定义一个LoginView类
//实现注册方法
//如果没有账户则需要注册
//如果有账号则直接进行登录
//实现登录功能
//判断用户输入的值是否正确
//如果正确则进入软件菜单
//如果错误则重新输入,限制次数只有5次,超过次数则程序停止,重新启动
//实现修改用户密码功能
//可以实现对用户名,密码,或者两者都可以进行修改即可。
public class Loginview 
    //给定属性,用户名和密码。
    private String userName = "";
    private String passWord;

    //注册功能
    public void regist() throws InterruptedException 
        TSUtility.loadSpecialEffects();
        System.out.println( "开始注册😊" );
        Scanner sc = new Scanner( System.in );
        System.out.println( "请输入账户名称😳(八位以内)" );
        String userName = TSUtility.readKeyBoard( 8, false );
        this.userName = userName;
        System.out.println( "请输入登录密码😳(八位以内)" );
        String passWord = TSUtility.readKeyBoard( 8, false );
        this.passWord = passWord;
        System.out.println( "注册成功,请登录!😀" );

    

    //登录功能
    public void login() throws InterruptedException 
        int count = 5;

        boolean flag = true;

        //登录界面的循环
        while (flag) 
            System.out.println( "********************🐱" );
            System.out.println( "***   <登录界面>   ***" );
            System.out.println( "***     (:      ***🐱" );
            System.out.println( "********************🐱" );

            //账号信息的输入与登录判断
            System.out.println( "请输入你的账户名称" );
            String userName = TSUtility.readKeyBoard( 4, false );
            System.out.println( "请输入你的登录密码" );
            String password = TSUtility.readKeyBoard( 8, false );

            if (this.userName.length() == 0 || this.passWord.length() == 0) 
                System.out.println( "未检测到你的账号信息,请重新输入或注册" );
                regist();
             else if (this.userName.equals( userName ) && this.passWord.equals( password )) 
                TSUtility.loadSpecialEffects();
                System.out.println( "登录成功,欢迎你:" + userName );
                flag = false;
             else 
                count--;
                if (count <= 0) 
                    System.out.println( "登录次数为零,无法登录,退出。" );
                    return;
                
                System.out.println( "登录失败,用户名不匹配或密码错误,还剩余" + count + "次登录机会,请重新输入" );
            
        
    



    //修改功能
    public void update() throws InterruptedException 
        boolean flag = true;
        while (flag) 
            System.out.println( "************************🐖" );
            System.out.println( "*********修改界面*********" );
            System.out.println( "*****   o(*^@^*)o  ***🐱" );
            System.out.println( "************************🐖" );

            System.out.println( "请输入您要修改的类型" );
            System.out.println( "(1)修改用户名" );
            System.out.println( "(2)修改密码" );
            System.out.println( "(3)修改用户名和密码" );
            System.out.println( "(4)不做修改" );

            Scanner sc = new Scanner( System.in );
            String options = sc.next();
            if (options.equals( "1" )) 
                System.out.println( "请输入新的账户名称" );
                String userName = TSUtility.readKeyBoard( 8, false );
                this.userName = userName;
                System.out.println( "账户修改成功啦ヽ(✿゚▽゚)ノ" );
             else if (options.equals( "2" )) 
                System.out.println( "请输入新的密码" );
                String passWord = TSUtility.readKeyBoard( 8, false );
                System.out.println( "密码修改成功啦ヽ(✿゚▽゚)ノ" );
             else if (options.equals( "3" )) 
                System.out.println( "请输入新的账户名称" );
                String userName = TSUtility.readKeyBoard( 8, false );
                this.userName = userName;
                System.out.println( "请输入新的密码" );
                String passWord = TSUtility.readKeyBoard( 8, false );
                this.passWord=passWord;
                System.out.println( "账户和密码都修改成功啦ヽ(✿゚▽゚)ノ" );
             else if (options.equals( "4" )) 
                System.out.println( "正在退出修改界面<( ̄ˇ ̄)/" );
                TSUtility.loadSpecialEffects();
                flag = false;
             else 
                System.out.println( "请输入1-4的整数哦 ̄へ ̄" );
            


        
    



团队调度管理界面TeamView



import domain.Employee;
import domain.Programmer;
import service.NameListService;
import service.TeamException;
import 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-退出(若需添加下一团队请退出此界面并选择添加团队 请选择(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.getDetailsForTeam() );
        
        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( "1-添加团队 2-查看团队 3-删除团队 4-退出 请选择(1-4)" );
            key = TSUtility.readMenuSelection();
            System.out.println();
            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.readConfirmSelection();
                        if (num < team.size()) 
                            System.out.println( "请确认是否删除(Y/N);(Enter" );
                            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.println( "是否退出(Y/N)" );
                    char yn = TSUtility.readConfirmSelection();
                    if (yn == 'Y') 
                        flag = false;
                    
                    break;
                default:
                    System.out.println( "输入信息有误,请重新输入" );
                    break;
            
         while (flag);
        return team;
    




主界面IndexView


import domain.Programmer;
import service.NameListService;
import service.ProjectService;
import service.TeamException;

import java.util.ArrayList;

public class IndexView 
    private final static Loginview loginVi = new Loginview();
    private final static NameListService nameListSer = new NameListService();
    private final static TeamView teamVi = new TeamView();
    private final static ProjectService projectSer = new ProjectService();
    private ArrayList<Programmer[]> manyTeam = null;


    public void menu() throws TeamException 
        boolean loopflag = true;
        char key = 0;

        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) 
            System.out.println( e.getMessage() );
        
        do 
            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( "⬇请选择:  " );
            key = TSUtility.readMenuSelection();
            switch (key) 
                case '1':
                    try 
                        loginVi.update();
                     catch (InterruptedException e) 
                        System.out.println( e.getMessage() );
                    
                    break;
                case '2':
                    try 
                        nameListSer.showEmployee();
                     catch (InterruptedException e) 
                        System.out.println( e.getMessage() );
                    
                    boolean loopFlagSec = true;
                    char keySec = 0;
                    do 
                        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.readMenuSelection();
                        switch (keySec) 
                            case '1':
                                try 
                                    nameListSer.addEmployee();
                                 catch (InterruptedException e) 
                                    System.out.println( e.getMessage() );
                                
                                break;
                            case '2':
                                try 
                                    nameListSer.showEmployee();
                                 catch (InterruptedException e) 
                                    System.out.println( e.getMessage() );
                                
                                break;
                            case '3':
                                System.out.println( "请输入要修改的员工ID" );
                                int i = TSUtility.readInt();
                                try 
                                    nameListSer.modifyEmployee( i );
                                 catch (InterruptedException e) 
                                    System.out.println( e.getMessage() );
                                
                                break;
                            case '4':
                                System.out.println( "请输入要删除的员工ID" );
                                int j = TSUtility.readInt();
                                nameListSer.delEmployee( j );
                                break;
                            case '5':
                                System.out.println( "确认是否要退出(Y/N)" );
                                char yn = TSUtility.readConfirmSelection();
                                if (yn == 'Y') 
                                    loopFlagSec = false;
                                
                                break;
                            default:
                                System.out.println( "输入有误,请重新输入!" );
                                break;
                        

                     while (loopFlagSec);

                    break;

                case '3':
                    manyTeam = teamVi.getManyteam();
                    break;
                case '4':
                    boolean loopFlagThr = true;
                    char keyThr = 0;
                    do 
                        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( "⬇请选择:  " );
                        keyThr = TSUtility.readMenuSelection();
                        switch (keyThr) 
                            case '1':
                                try 
                                    projectSer.addProject();
                                 catch (InterruptedException e) 
                                    System.out.println( e.getMessage() );
                                
                                break;
                            case '2':
                                if(manyTeam.size()!=0)
                                    for (Programmer[] pro : manyTeam) //增强for循环使用
                                        projectSer.dealingPro( pro );
                                    
                                else 
                                    System.out.println("无团队");
                                

                            case '3':
                                try 
                                    projectSer.showPro();
                                 catch (InterruptedException e) 
                                    System.out.println( e.getMessage() );
                                
                                break;
                            case '4':
                                System.out.println( "请输入要删除的项目ID" );
                                int j = TSUtility.readInt();
                                projectSer.delPro( j );
                                break;
                            case '5':
                                System.out.println("确认是否退出(Y/N)");
                                char yn = TSUtility.readConfirmSelection();
                                if (yn=='Y')
                                    loopFlagThr =false;
                                
                                break;
                            default:
                                System.out.println( "输入有误,请重新输入" );
                                break;
                        

                     while (loopFlagThr);
                    break;

                case '5':
                    System.out.println( "是否确认退出(Y/N)" );
                    char yn = TSUtility.readConfirmSelection();
                    if (yn == 'Y') 
                        loopflag = false;
                    
                    break;
                default:
                    break;


            

         while (loopflag);
    

    public static void main(String[] args) throws TeamException 
        new IndexView().menu();
    



遇到的BUG以及解决以及后续优化

1)载入界面注册功能输出问题:
问题如下:登录账号密码错误时候会重复注册

解决方法:将注册写在另一个方法,在登陆判定失败时候才载入注册界面
(详细代码见 Loginview)

2):1开发人员添加bug,删除序号没能动态变化.
解决方法:使用动态ID。

  for (int i = 0; i < employees.size(); i++) 
            if (employees.get( i ).getId() == id) 
                employees.remove( i );
                for (i = id; i <= employees.size(); i++) 
                    //个人理解是不停的让后面的序号-1覆盖前面的从而实现删除元素后前后序号排序正常。
                    employees.get( i - 1 ).setId( employees.get( i - 1 ).getId() - 1 );
                
                flag = true;
            
        

3)在开发人员管理中添加的成员在团队成员后,在团队管理界面数据未能同步。
解决方法:将集合改为静态并且,使用集合的isEmpty方法。

4)添加团队成员失败,没有进行正确判定,直接抛出异常状态

应该修改为:

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

(其实是自己马虎写漏了!,后续找了半天…)

5)团队成员tid排序紊乱,tid与id间隔不明显无法精确显示

//编写改变后的id
int i = 1;
for (int j = 0; j < total; j++) 
    team[j].setMemberId( i++ );

增加间隔符增加显示间隔

6)项目分配优化问题:
项目删除:如果删除正在被开发的项目未作询问
修改如下:

//删除所选择的项目
public void delPro(int id )throws TeamException
    boolean flag = false;
    for (int i = 0; i < pro.size(); i++) 
        if (pro.get( i ).getStatus())
        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;
        
        else //如果我使用,删除正在开发的项目应抛出异常
            throw new TeamException("该项目正在开发中");
        
    
    就算在开发中我也要删除如何?
    else 
//                throw new TeamException("当前项目正在被开发,无法删除!");
                System.out.println("当前项目正在被开发,无法删除!");
                System.out.println("如果坚持删除请选择1,退出选择2");
                boolean loopflag = true;
                char key = TSUtility.readMenuSelection();
                do 
                    switch (key)
                        case '1':
                            for (int j = 0; j < pro.size(); j++) 
                                if (pro.get( j ).getProId()==id)
                                    pro.remove( j );
                                    for (j  = id ;j<pro.size();j++) 
                                        pro.get( j-1 ).setProId( pro.get( j-1 ).getProId()-1 );
                                    
                                
                            
                            System.out.println("删除成功");
                            count--;
                            loopflag = false;
                            break;
                        case '2':
                            loopflag = false;
                            break;
                        default:
                            System.out.println("输入有误");
                            break;
                    
                while (loopflag);
            
        
        	增加了一套循环判断

7)使用优化:

主要为输出语句更加

以上是关于实践项目《项目开发团队分配管理软件》的主要内容,如果未能解决你的问题,请参考以下文章

对软件工程课程的期望

项目管理学习总结——项目管理最佳实践入门

软件工程实践 · 团队项目 第一次作业

CODING 敏捷项目管理全新改版上线

软件工程的实践项目课程的自我目标

软件工程实践项目课程的自我目标