• Java面向对象项目三:开发团队调度软件


    目录

    一、工具类及数据类提供

    TSUtility工具类

    Data数据类

    二、Equipment接口及实现子类的设计

     Equipment接口

    NoteBook类

    PC类

    Printer类

    三、Employee类及其子类的设计

     Employee类

    Programmer类

    Designer类

    Architect类

    四、NameListService属性和构造器的实现

     NameListService类

    TeamException类

    测试NameListService类的getAllEmployees()

    测试NameListService类的getEmployees()

    五、TeamService类的设计

    六、TeamView类的设计

    模拟实现一个基于文本界面的《开发团队调度软件》

    该软件主要实现以下功能:

    • 软件启动时,根据给定的数据创建公司员工部分成员列表(数组)
    • 根据菜单提示,基于现有的公司成员,组建一个开发团队以开发一个新的项目
    • 组建过程中包括将成员插入到团队中,或从团队中删除某成员,还可以列出团队成员中现有的成员列表
    • 开发团队包括架构师、设计师和程序员

    一、工具类及数据类提供

    TSUtility工具类

    1. package com.light.team.view;
    2. /**
    3. * @Description 项目提供了Utility.java类,可以用来方便实现键盘访问
    4. * @author light
    5. *
    6. */
    7. import java.util.*;
    8. public class TSUtility {
    9. private static Scanner scanner=new Scanner(System.in);
    10. /**
    11. * @Description 该方法读取键盘,如果用户输入‘1’--‘4’中的任意字符,则方法返回。
    12. * @return 返回值为用户输入的数字
    13. */
    14. public static char readMenuSelection() {
    15. char c;
    16. for(;;) {
    17. String str=readKeyBoard(1,false);
    18. c=str.charAt(0);
    19. if(c!='1'&&c!='2'&&c!='3'&&c!='4') {
    20. System.out.print("选择错误,请重新输入:");
    21. }else break;
    22. }
    23. return c;
    24. }
    25. /**
    26. * 该方法框提示并等待,直到直接按回车键
    27. */
    28. public static void readReturn() {
    29. System.out.println("按回车键继续...");
    30. readKeyBoard(100,true);
    31. }
    32. /**
    33. * 该方法从键盘中读取一个长度不超过2的整数
    34. * @return 返回读取到的整数值
    35. */
    36. public static int readInt() {
    37. int n;
    38. for(;;) {
    39. String str=readKeyBoard(2,false);
    40. try {
    41. n=Integer.parseInt(str);
    42. break;
    43. }catch(NumberFormatException e) {
    44. System.out.print("数字输入错误,请重新输入:");
    45. }
    46. }
    47. return n;
    48. }
    49. /**
    50. * 从键盘中读取用户选择‘y’或‘N',
    51. * @return 将结果返回
    52. */
    53. public static char redConfirmSelection() {
    54. char c;
    55. for(;;) {
    56. String str=readKeyBoard(1,false).toUpperCase();
    57. c=str.charAt(0);
    58. if(c=='Y'||c=='N') {
    59. break;
    60. }else {
    61. System.out.print("选择错入,请重新选择:");
    62. }
    63. }
    64. return c;
    65. }
    66. private static String readKeyBoard(int limit,boolean blankReturn) {
    67. String line="";
    68. while(scanner.hasNextLine()) {
    69. line=scanner.nextLine();
    70. if(line.length()==0) {
    71. if(blankReturn)
    72. return line;
    73. else continue;
    74. }
    75. if(line.length()<1||line.length()>limit) {
    76. System.out.print("输入长度(不大于"+limit+"),错误,请重新输入:");
    77. continue;
    78. }
    79. break;
    80. }
    81. return line;
    82. }
    83. }

    Data数据类

    1. package com.light.team.service;
    2. public class Data {
    3. public static final int EMPLOYEE=10;
    4. public static final int PROGRAMMER=11;
    5. public static final int DESIGNER=12;
    6. public static final int ARCHITECT=13;
    7. public static final int PC=21;
    8. public static final int NOTEBOOK=22;
    9. public static final int PRINTER=23;
    10. //Employee :10,id,name,age,salary
    11. //programmer:11,id,name,age,salary
    12. //Designer :12,id,name,age,salary,bonus
    13. //Architer:13,id,name,age,salary,bonus,stock
    14. public static final String[][] EMPLOYEES = {
    15. {"10", "1", "马 云", "22", "3000"},
    16. {"13", "2", "马化腾", "32", "18000", "15000", "2000"},
    17. {"11", "3", "李彦宏", "23", "7000"},
    18. {"11", "4", "刘强东", "24", "7300"},
    19. {"12", "5", "雷 军", "28", "10000", "5000"},
    20. {"11", "6", "任志强", "22", "6800"},
    21. {"12", "7", "柳传志", "29", "10800","5200"},
    22. {"13", "8", "杨元庆", "30", "19800", "15000", "2500"},
    23. {"12", "9", "史玉柱", "26", "9800", "5500"},
    24. {"11", "10", "丁 磊", "21", "6600"},
    25. {"11", "11", "张朝阳", "25", "7100"},
    26. {"12", "12", "杨致远", "27", "9600", "4800"}
    27. };
    28. //如下的EQUIPMENTS数组与上面的EMPLOYEES数组元素一一对应
    29. //PC :21, model, display
    30. //NoteBook:22, model, price
    31. //Printer :23, name, type
    32. public static final String[][] EQUIPMENTS = {
    33. {},
    34. {"22", "联想T4", "6000"},
    35. {"21", "戴尔", "NEC17寸"},
    36. {"21", "戴尔", "三星 17寸"},
    37. {"23", "佳能 2900", "激光"},
    38. {"21", "华硕", "三星 17寸"},
    39. {"21", "华硕", "三星 17寸"},
    40. {"23", "爱普生20K", "针式"},
    41. {"22", "惠普m6", "5800"},
    42. {"21", "戴尔", "NEC 17寸"},
    43. {"21", "华硕","三星 17寸"},
    44. {"22", "惠普m6", "5800"}
    45. };
    46. }

    二、Equipment接口及实现子类的设计

     Equipment接口

    1. package com.light.team.domain;
    2. public interface Euquipment {
    3. public String getDescription();
    4. }

    NoteBook

    1. package com.light.team.domain;
    2. public class NoteBook implements Equipment{
    3. private String model;//显示器型号
    4. private double price;//显示器价格
    5. /**
    6. * 构造器
    7. */
    8. public NoteBook() {
    9. super();
    10. }
    11. /**
    12. * @param model 显示器型号
    13. * @param price 显示器价格
    14. */
    15. public NoteBook(String model, double price) {
    16. super();
    17. this.model = model;
    18. this.price = price;
    19. }
    20. public String getModel() {
    21. return model;
    22. }
    23. public void setModel(String model) {
    24. this.model = model;
    25. }
    26. public double getPrice() {
    27. return price;
    28. }
    29. public void setPrice(double price) {
    30. this.price = price;
    31. }
    32. /**
    33. * @Override 实现类接口的方法,返回各自的属性信息
    34. */
    35. public String getDescription() {
    36. return model+"("+price+")";
    37. }
    38. }

    PC类

    1. package com.light.team.domain;
    2. public class PC implements Equipment{
    3. private String model;//显示器型号
    4. private String display;//显示器名称
    5. public String getModel() {
    6. return model;
    7. }
    8. public void setModel(String model) {
    9. this.model = model;
    10. }
    11. public String getDeiplay() {
    12. return display;
    13. }
    14. public void setDeiplay(String display) {
    15. this.display = display;
    16. }
    17. /**
    18. * @param model 显示器型号
    19. * @param deiplay 显示器名称
    20. */
    21. public PC(String model, String display) {
    22. super();
    23. this.model = model;
    24. this.display = display;
    25. }
    26. /**
    27. * 无参构造器
    28. */
    29. public PC() {
    30. super();
    31. }
    32. @Override
    33. public String getDescription() {
    34. return model+"("+display+")";
    35. }
    36. }

    Printer类

    1. package com.light.team.domain;
    2. public class Printer implements Equipment {
    3. private String name;//显示器型号
    4. private String type;//显示器类型
    5. /**
    6. * 无参构造器
    7. */
    8. public Printer() {
    9. super();
    10. }
    11. /**
    12. * @param name 显示器型号
    13. * @param type 显示器类型
    14. */
    15. public Printer(String name, String type) {
    16. super();
    17. this.name = name;
    18. this.type = type;
    19. }
    20. public String getName() {
    21. return name;
    22. }
    23. public void setName(String name) {
    24. this.name = name;
    25. }
    26. public String getType() {
    27. return type;
    28. }
    29. public void setType(String type) {
    30. this.type = type;
    31. }
    32. /**
    33. * 实现类实现接口的方法,返回各自属性的信息
    34. */
    35. public String getDescription() {
    36. return name+"("+type+")";
    37. }
    38. }

    三、Employee类及其子类的设计

     Employee类

    1. package com.light.team.domain;
    2. public class Employee {
    3. private int id;
    4. private String name;
    5. private int age;
    6. private double salary;
    7. public int getId() {
    8. return id;
    9. }
    10. public void setId(int id) {
    11. this.id = id;
    12. }
    13. public String getName() {
    14. return name;
    15. }
    16. public void setName(String name) {
    17. this.name = name;
    18. }
    19. public int getAge() {
    20. return age;
    21. }
    22. public void setAge(int age) {
    23. this.age = age;
    24. }
    25. public double getSalary() {
    26. return salary;
    27. }
    28. public void setSalary(double salary) {
    29. this.salary = salary;
    30. }
    31. /**
    32. * @param id 团队成员id
    33. * @param name 团队成员姓名
    34. * @param age 团队成员年龄
    35. * @param salary 团队成员工资
    36. */
    37. public Employee(int id, String name, int age, double salary) {
    38. super();
    39. this.id = id;
    40. this.name = name;
    41. this.age = age;
    42. this.salary = salary;
    43. }
    44. /**
    45. * 无参构造器
    46. */
    47. public Employee() {
    48. super();
    49. }
    50. public String getDetails() {
    51. return id+"\t"+name+"\t"+age+"\t"+salary;
    52. }
    53. @Override
    54. public String toString() {
    55. return getDetails();
    56. }
    57. }

    Programmer类

    1. package com.light.team.domain;
    2. import com.light.team.service.Status;
    3. public class Programmer extends Employee {
    4. private int memberId;//用来记录成员加入开发团队后在团队中的ID
    5. //Status 是service包下自定义的类,
    6. //声明三个属性,分别表示三种状态:
    7. //FREE-空闲
    8. //BUSY-已加入开发团队
    9. //VOCATION-正在休假
    10. private Status status;
    11. private Equipment equipment;
    12. public int getMemberId() {
    13. return memberId;
    14. }
    15. public void setMemberId(int memberId) {
    16. this.memberId = memberId;
    17. }
    18. public Status getStatus() {
    19. return status;
    20. }
    21. public void setStatus(Status status) {
    22. this.status = status;
    23. }
    24. public Equipment getEquipment() {
    25. return equipment;
    26. }
    27. public void setEquipment(Equipment equipment) {
    28. this.equipment = equipment;
    29. }
    30. /**
    31. * 无参构造器
    32. */
    33. public Programmer() {
    34. super();
    35. }
    36. /**
    37. * @param id
    38. * @param name
    39. * @param age
    40. * @param salary
    41. */
    42. public Programmer(int id, String name, int age, double salary,Equipment equipment) {
    43. super(id, name, age, salary);
    44. this.equipment=equipment;
    45. }
    46. @Override
    47. public String toString() {
    48. return super.getDetails()+"\t程序员\t"+status+"\t\t\t"+equipment.getDescription();
    49. }
    50. public String getDetail() {
    51. return memberId+"/"+getId()+"\t"+getName()+"\t"+getAge()+"\t"+getSalary();
    52. }
    53. public String getDetailsFromTeam() {
    54. return getDetail()+"\t程序员";
    55. }
    56. }

    Designer类

    1. package com.light.team.domain;
    2. public class Designer extends Programmer{
    3. private double bonus;//奖金
    4. public double getBonus() {
    5. return bonus;
    6. }
    7. public void setBonus(double bonus) {
    8. this.bonus = bonus;
    9. }
    10. public Designer() {
    11. super();
    12. }
    13. /**
    14. * @param id
    15. * @param name
    16. * @param age
    17. * @param salary
    18. * @param equipment
    19. */
    20. public Designer(int id, String name, int age, double salary,Equipment equipment,double bonus) {
    21. super(id, name, age, salary,equipment);
    22. this.bonus=bonus;
    23. }
    24. @Override
    25. public String toString() {
    26. return getDetails()+"\t设计师\t"+getStatus()+"\t"+bonus+"\t\t"+getEquipment().getDescription();
    27. }
    28. public String getDetailsFromTeam() {
    29. return getDetail()+"\t设计师"+"\t"+getBonus();
    30. }
    31. }

    Architect类

    1. package com.light.team.domain;
    2. public class Architect extends Designer {
    3. private int stock;//股票
    4. public int getStock() {
    5. return stock;
    6. }
    7. public void setStock(int stock) {
    8. this.stock = stock;
    9. }
    10. public Architect() {
    11. super();
    12. }
    13. /**
    14. * @param id
    15. * @param name
    16. * @param age
    17. * @param salary
    18. * @param equipment
    19. * @param bonus
    20. */
    21. public Architect(int id, String name, int age, double salary, Equipment equipment, double bonus,int stock) {
    22. super(id, name, age, salary, equipment, bonus);
    23. this.stock=stock;
    24. }
    25. @Override
    26. public String toString() {
    27. return getDetails()+"\t架构师\t"+getStatus()+"\t"+getBonus()+"\t"+stock+"\t"+getEquipment().getDescription();
    28. }
    29. public String getDetailsFromTeam() {
    30. return getDetail()+"\t架构师"+"\t"+getBonus()+"\t"+getStock();
    31. }
    32. }

    四、NameListService属性和构造器的实现

     NameListService类

    1. package com.light.team.service;
    2. /**
    3. * @Description 负责将data中的数据封装到Employee[]数组中,
    4. * 同时提供相关操作Employee[]的方法
    5. * @author light
    6. *
    7. */
    8. import static com.light.team.service.Data.*;
    9. import com.light.team.domain.*;
    10. public class NameListService {
    11. private Employee[] employees;
    12. /**
    13. * 对employees数组及数组元素进行初始化
    14. */
    15. public NameListService() {
    16. // 根据项目提供给的data类构建相应大小的employees数组
    17. // 再根据data类的数据构造不同的对象,包括Employee、Programmer、
    18. // Designer和Architect
    19. // 将对象存进数组中
    20. employees = new Employee[EMPLOYEES.length];
    21. for (int i = 0; i < employees.length; i++) {
    22. // 获取员工类型
    23. int type = Integer.parseInt(EMPLOYEES[i][0]);
    24. // 获取员工四项基本信息
    25. int id = Integer.parseInt(EMPLOYEES[i][1]);
    26. String name = EMPLOYEES[i][2];
    27. int age = Integer.parseInt(EMPLOYEES[i][3]);
    28. double salary = Double.parseDouble(EMPLOYEES[i][4]);
    29. Equipment equipment;
    30. double bonus;
    31. int stock;
    32. switch (type) {
    33. case EMPLOYEE:
    34. employees[i] = new Employee(id, name, age, salary);
    35. break;
    36. case PROGRAMMER:
    37. equipment = createEquipment(i);
    38. employees[i] = new Programmer(id, name, age, salary,equipment);
    39. break;
    40. case DESIGNER:
    41. equipment = createEquipment(i);
    42. bonus = Double.parseDouble(EMPLOYEES[i][5]);
    43. employees[i] = new Designer(id, name, age, salary, equipment, bonus);
    44. break;
    45. case ARCHITECT:
    46. equipment = createEquipment(i);
    47. bonus = Double.parseDouble(EMPLOYEES[i][5]);
    48. stock = Integer.parseInt(EMPLOYEES[i][6]);
    49. employees[i] = new Architect(id, name, age, salary, equipment, bonus, stock);
    50. break;
    51. }
    52. }
    53. }
    54. /**
    55. * 获取指定index位置上的员工的设备
    56. *
    57. * @param index
    58. * @return
    59. */
    60. private Equipment createEquipment(int index) {
    61. int e = Integer.parseInt(EQUIPMENTS[index][0]);
    62. String model = EQUIPMENTS[index][1];
    63. switch (e) {
    64. case PC:// 21
    65. String display = EQUIPMENTS[index][2];
    66. return new PC(model, display);
    67. case NOTEBOOK:// 22
    68. double price = Double.parseDouble(EQUIPMENTS[index][2]);
    69. return new NoteBook(model, price);
    70. case PRINTER:// 23
    71. String type = EQUIPMENTS[index][2];
    72. return new Printer(model, type);
    73. }
    74. return null;
    75. }
    76. /**
    77. * 获取当前所有员工
    78. * @return
    79. */
    80. public Employee[] getALLEmpolyees() {
    81. return employees;
    82. }
    83. /**
    84. *
    85. * @param id
    86. * @return 获取指定id的员工
    87. * @throws TeamException
    88. * @throws Exception
    89. */
    90. public Employee getEmpolyees(int id) throws TeamException{
    91. for(int i=0;i
    92. if(employees[i].getId()==id) {
    93. return employees[i];
    94. }
    95. }
    96. throw new TeamException("找不到指定员工");
    97. }
    98. }

    TeamException类

    1. package com.light.team.service;
    2. /**
    3. * 自定义异常类
    4. * @author light
    5. *
    6. */
    7. public class TeamException extends Exception{
    8. static final long serialVersionUID = -3387516993124888948L;
    9. public TeamException() {
    10. super();
    11. }
    12. /**
    13. * @param message
    14. */
    15. public TeamException(String message) {
    16. super(message);
    17. }
    18. }

    测试NameListService类的getAllEmployees()

    1. package com.light.team.junit;
    2. import org.junit.jupiter.api.Test;
    3. import com.light.team.domain.Employee;
    4. import com.light.team.service.NameListService;
    5. /**
    6. * 测试NameListService类
    7. * @author light
    8. */
    9. public class NameListServiceTest {
    10. @Test
    11. public void testGetAllEmployees() {
    12. NameListService service=new NameListService();
    13. Employee[] employees=service.getAllEmployees();
    14. for(int i=0;i
    15. System.out.println(employees[i]);
    16. }
    17. }
    18. }

    测试结果如下:

    测试NameListService类的getEmployees()

    1. package com.light.team.junit;
    2. import org.junit.jupiter.api.Test;
    3. import com.light.team.domain.Employee;
    4. import com.light.team.service.NameListService;
    5. /**
    6. * 测试NameListService类
    7. * @author light
    8. */
    9. public class NameListServiceTest {
    10. @Test
    11. public void testGetEmployee() throws TeamException {
    12. NameListService service=new NameListService();
    13. int i=1;
    14. System.out.println(service.getEmployee(i));
    15. }
    16. }

    测试结果如下:

    五、TeamService类的设计

    1. package com.light.team.service;
    2. import com.light.team.domain.*;
    3. /**
    4. * 开发团队成员管理:添加、删除等
    5. * @author light
    6. *
    7. */
    8. public class TeamService {
    9. private static int counter=1;//给memberId赋值使用
    10. private static final int MAX_MEMBER=5;//限制开发团队人数
    11. private Programmer[] team=new Programmer[MAX_MEMBER];//保存开发团队成员
    12. private int total=0;//记录开发团队中实际人数
    13. public TeamService() {
    14. super();
    15. }
    16. /**
    17. *
    18. * @return 获取开发团队中的所有成员
    19. */
    20. public Programmer[] getTeam() {
    21. Programmer[] team=new Programmer[total];
    22. for(int i=0;i
    23. team[i]=this.team[i];
    24. }
    25. return team;
    26. }
    27. public void addMember(Employee e) throws TeamException {
    28. //成员已满无法添加
    29. if(total>=MAX_MEMBER) {
    30. throw new TeamException("成员已满无法添加");
    31. }
    32. //该成员不是开发人员,无法添加
    33. if(!(e instanceof Programmer)) {
    34. throw new TeamException("该成员不是开发人员,无法添加");
    35. }
    36. //该员工已在本开发团队中
    37. if(isExcit(e)) {
    38. throw new TeamException("该员工已在本开发团队中");
    39. }
    40. //该员工已是某团队成员
    41. Programmer p=(Programmer)e;
    42. if("BUSY".equals(p.getStatus().getNAME())) {
    43. throw new TeamException("该员工已是某团队成员");
    44. }
    45. //该员工正在休假,无法添加
    46. if("VOCATION".equals(p.getStatus().getNAME())) {
    47. throw new TeamException("该员工正在休假,无法添加");
    48. }
    49. //获取团队架构师、设计师、程序员的个数
    50. int numOfArc=0,numOfDes=0,numOfPro=0;
    51. for(int i=0;i
    52. if(team[i] instanceof Architect) {
    53. numOfArc++;
    54. }else if(team[i] instanceof Designer) {
    55. numOfDes++;
    56. }else if(team[i] instanceof Programmer){
    57. numOfPro++;
    58. }
    59. }
    60. //团队中最多只能有一名架构师
    61. //团队中最多只能有两名设计师
    62. //团队中最多只能有三名程序员
    63. if(p instanceof Architect) {
    64. if(numOfArc>=1) {
    65. throw new TeamException("团队中最多只能有一名架构师");
    66. }
    67. }else if(p instanceof Designer) {
    68. if(numOfDes>=2) {
    69. throw new TeamException("团队中最多只能有两名设计师");
    70. }
    71. }else if(p instanceof Programmer) {
    72. if(numOfPro>=3) {
    73. throw new TeamException("团队中最多只能有三名程序员");
    74. }
    75. }
    76. //将成员添加到团队中
    77. team[total++]=p;
    78. //修改成员状态
    79. p.setStatus(Status.BUSY);
    80. p.setMemberId(counter++);
    81. }
    82. private boolean isExcit(Employee e) {
    83. for(int i=0;i
    84. if(team[i].getId()==e.getId()) {
    85. return true;
    86. }
    87. }
    88. return false;
    89. }
    90. /**
    91. * 删除指定memberId的成员
    92. * @param memberId
    93. * @throws TeamException
    94. */
    95. public void removeMember(int memberId) throws TeamException {
    96. int i;
    97. //寻找指定memberId的成员
    98. for(i=0;i
    99. if(team[i].getMemberId()==memberId) {
    100. team[i].setStatus(Status.FREE);
    101. break;
    102. }
    103. }
    104. if(i==total) {
    105. throw new TeamException("未找到指定memberId的成员,删除失败");
    106. }
    107. //找到指定memberId的成员,进行删除
    108. for(int j=i+1;j
    109. team[j-1]=team[j];
    110. }
    111. team[--total]=null;
    112. }
    113. }

    六、TeamView类的设计

    1. package com.light.team.view;
    2. //开发团队调度软件
    3. //从公司中抽调员工进行项目开发
    4. import com.light.team.domain.Employee;
    5. import com.light.team.domain.Programmer;
    6. import com.light.team.service.NameListService;
    7. import com.light.team.service.TeamException;
    8. import com.light.team.service.TeamService;
    9. public class TeamView {
    10. private NameListService listSvc=new NameListService();
    11. private TeamService teamSvc=new TeamService();
    12. public void enterMain() {
    13. boolean isFlag=true;
    14. char menu=0;
    15. while(isFlag) {
    16. if(menu!='1') {
    17. listAllEmplouees();
    18. }
    19. System.out.print("1-团队列表 2-添团队成员 3-删除团队成员 4-退出 请选择:");
    20. menu = TSUtility.readMenuSelection();
    21. switch(menu) {
    22. case '1':
    23. getTeam();
    24. break;
    25. case '2':
    26. addMember();
    27. break;
    28. case '3':
    29. deleteMember();
    30. break;
    31. case '4':
    32. System.out.print("确认要退出吗(Y/N):");
    33. char isExit = TSUtility.redConfirmSelection();
    34. if(isExit=='Y') {
    35. isFlag=false;
    36. System.out.println("谢谢使用,再见!");
    37. }else {
    38. break;
    39. }
    40. }
    41. }
    42. }
    43. /**
    44. * 显示员工主界面
    45. */
    46. private void listAllEmplouees() {
    47. System.out.println("---------------------------显示公司所有员工信息---------------------\n");
    48. System.out.println("ID\t姓名\t年龄\t工资\t职位\t状态\t奖金\t股票\t 领用设备");
    49. Employee[] employees = listSvc.getALLEmpolyees();
    50. for(int i=0;i
    51. System.out.println(employees[i]);
    52. }
    53. }
    54. private void getTeam() {
    55. Programmer[] team = teamSvc.getTeam();
    56. System.out.println("--------------------------------团队成员列表--------------------------------");
    57. if(team==null||team.length==0) {
    58. System.out.println("该团队没有成员");
    59. }
    60. else {
    61. System.out.println("TID/ID\t姓名\t年龄\t工资\t职位\t奖金\t股票");
    62. for(int i=0;i
    63. System.out.println(team[i].getDetailsFromTeam());
    64. }
    65. }
    66. System.out.println("-------------------------------------------------------------------");
    67. }
    68. private void addMember() {
    69. System.out.println("----------------------------------添加团队成员-------------------------------------");
    70. System.out.print("请输入要添加员工id:");
    71. int id = TSUtility.readInt();
    72. try {
    73. Employee emp = listSvc.getEmpolyees(id);
    74. teamSvc.addMember(emp);
    75. System.out.println("添加成功");
    76. } catch (TeamException e) {
    77. System.out.println("添加失败,原因:"+e.getMessage());
    78. }
    79. //按回车键继续...
    80. TSUtility.readReturn();
    81. }
    82. private void deleteMember() {
    83. System.out.println("----------------------------删除团队成员-----------------------------");
    84. System.out.print("请输入要删除员工的TID:");
    85. int memberId = TSUtility.readInt();
    86. System.out.print("是否要删除(Y/N):");
    87. char isDelete = TSUtility.redConfirmSelection();
    88. if(isDelete=='N') {
    89. return;
    90. }
    91. try {
    92. teamSvc.removeMember(memberId);
    93. System.out.println("删除成功");
    94. } catch (TeamException e) {
    95. System.out.println("删除失败,原因:"+e.getMessage());
    96. }
    97. TSUtility.readReturn();
    98. }
    99. public static void main(String[] args) {
    100. TeamView view=new TeamView();
    101. view.enterMain();
    102. }
    103. }

  • 相关阅读:
    electron安装失败时配置
    SpringMVC 域对象共享数据
    springboot瑞吉外卖
    java中循环遍历某个文件夹下面的文件,不压缩自身的文件夹,然后压缩成tar.gz格式,压缩失败报异常,代码类编写?
    linux内核驱动开发
    英语 翻译 时态及语法检查 句子分层结构 例句 讯飞星火远远超越GPT4 AI大模型测评
    大数据Flink(九十四):DML:TopN 子句
    计算机操作系统第四版第八章磁盘存储器的管理—课后习题答案
    二叉树 | 指针pre | 最值、众数、累加树 | leecode刷题笔记
    蓝蓝设计提供地理信息系统GIS界面设计
  • 原文地址:https://blog.csdn.net/zssxcj/article/details/127693344