• JAVA基础小结(项目三)


    模拟实现一个基于文本界面的 开发团队调度软件
    熟悉 Java 面向对象的高级特性,进一步掌握编程技巧和调试技巧
    主要涉及以下知识点:
    Ø 类的继承性和多态性
    Ø 对象的值传递、接口
    Ø static final 修饰符
    Ø 特殊类的使用:包装类 、抽象 类、内部类
    Ø 异常处理
    该软件实现以下功能:
    Ø 软件启动时,根据给定的数据创建公司部分成员列表(数组)
    Ø 根据菜单提示,基于现有的 公司成员 ,组建一个 开发团队 以开发一个新的项目
    Ø 组建过程包括将成员插入到团队中,或从团队中删除某成员,还可以列出团队中现有成员的列表
    Ø 开发团队成员包括架构师、设计师和程序员

     需求说明

      本软件采用单级菜单方式工作。当软件运行时,主界面显示公司成员的列表,如下:

    -------------------------------------开发团队调度软件--------------------------------------

    ID     姓名      年龄    工资         职位      状态      奖金        股票     领用设备

     1      马 云      22      3000.0

     2      马化腾   32       18000.0  架构师   FREE    15000.0   2000    联想T4(6000.0)

     3      李彦宏   23       7000.0    程序员   FREE                                戴尔(NEC17)

     4      刘强东   24       7300.0    程序员   FREE                                戴尔(三星 17)

     5      雷军      28       10000.0  设计师   FREE    5000.0                 佳能 2900(激光)

     ……

    ----------------------------------------------------------------------------------------------

    1-团队列表  2-添加团队成员  3-删除团队成员 4-退出   请选择(1-4)_

    当选择“添加团队成员”菜单时,将执行从列表中添加指定(通过ID)成员到开发团队的功能:

    1-团队列表  2-添加团队成员  3-删除团队成员  4-退出   请选择(1-4)2

    ---------------------添加成员---------------------

    请输入要添加的员工ID2

    添加成功

    按回车键继续...

    添加成功后,按回车键将重新显示主界面。

    开发团队人员组成要求:

    最多一名架构师
    最多两名设计师
    最多三名程序员

    如果添加操作因某种原因失败,将显示类似以下信息(失败原因视具体原因而不同):

    1-团队列表  2-添加团队成员  3-删除团队成员 4-退出   请选择(1-4)2

    ---------------------添加成员---------------------

    请输入要添加的员工ID2

    添加失败,原因:该员工已是某团队成员

    按回车键继续...

      失败信息包含以下几种:

    成员已满,无法添加
    该成员不是开发人员,无法添加
    该员工已在本开发团队中
    该员工已是某团队成员
    该员正在休假,无法添加
    团队中至多只能有一名架构师
    团队中至多只能有两名设计师
    团队中至多只能有三名程序员

    当选择“删除团队成员”菜单时,将执行从开发团队中删除指定(通过TeamID)成员的功能:

    1-团队列表  2-添加团队成员  3-删除团队成员 4-退出   请选择(1-4)3

    ---------------------删除成员---------------------

    请输入要删除员工的TID1

    确认是否删除(Y/N)y

    删除成功

    按回车键继续...

      删除成功后,按回车键将重新显示主界面。

    提供的文件

    数据文件

    1. package com.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. //Architect : 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. //如下的EQIPMENTS数组与上面的EMPLOYEES数组元素一一对应
    29. //PC :21, model, display
    30. //NoteBook:22, model, price
    31. //Printer :23, type, name
    32. public static final String[][] EQIPMENTS = {
    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. }

    工具类:

    1. package com.team.view;
    2. import java.util.*;
    3. public class TSUtility {
    4. private static Scanner scanner = new Scanner(System.in);
    5. public static char readMenuSelection() {
    6. char c;
    7. for (; ; ) {
    8. String str = readKeyBoard(1, false);
    9. c = str.charAt(0);
    10. if (c != '1' && c != '2' &&
    11. c != '3' && c != '4') {
    12. System.out.print("选择错误,请重新输入:");
    13. } else break;
    14. }
    15. return c;
    16. }
    17. public static void readReturn() {
    18. System.out.print("按回车键继续...");
    19. readKeyBoard(100, true);
    20. }
    21. public static int readInt() {
    22. int n;
    23. for (; ; ) {
    24. String str = readKeyBoard(2, false);
    25. try {
    26. n = Integer.parseInt(str);
    27. break;
    28. } catch (NumberFormatException e) {
    29. System.out.print("数字输入错误,请重新输入:");
    30. }
    31. }
    32. return n;
    33. }
    34. public static char readConfirmSelection() {
    35. char c;
    36. for (; ; ) {
    37. String str = readKeyBoard(1, false).toUpperCase();
    38. c = str.charAt(0);
    39. if (c == 'Y' || c == 'N') {
    40. break;
    41. } else {
    42. System.out.print("选择错误,请重新输入:");
    43. }
    44. }
    45. return c;
    46. }
    47. private static String readKeyBoard(int limit, boolean blankReturn) {
    48. String line = "";
    49. while (scanner.hasNextLine()) {
    50. line = scanner.nextLine();
    51. if (line.length() == 0) {
    52. if (blankReturn) return line;
    53. else continue;
    54. }
    55. if (line.length() < 1 || line.length() > limit) {
    56. System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");
    57. continue;
    58. }
    59. break;
    60. }
    61. return line;
    62. }
    63. }

    domain包下的代码:

    接口:

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

    三个实现接口的设备类:

    1. package com.team.domain;
    2. public class PC implements Equipment{
    3. private String model; //机器型号
    4. private String display; //显示器名称
    5. public PC() {
    6. super();
    7. }
    8. public PC(String model, String display) {
    9. super();
    10. this.model = model;
    11. this.display = display;
    12. }
    13. public String getModel() {
    14. return model;
    15. }
    16. public void setModel(String model) {
    17. this.model = model;
    18. }
    19. public String getDisplay() {
    20. return display;
    21. }
    22. public void setDisplay(String display) {
    23. this.display = display;
    24. }
    25. @Override
    26. public String getDescription() {
    27. return model + "(" + display + ")";
    28. }
    29. }
    1. package com.team.domain;
    2. public class NoteBook implements Equipment {
    3. private String model;
    4. private double price;
    5. public NoteBook() {
    6. super();
    7. }
    8. public NoteBook(String model, double price) {
    9. super();
    10. this.model = model;
    11. this.price = price;
    12. }
    13. public String getModel() {
    14. return model;
    15. }
    16. public void setModel(String model) {
    17. this.model = model;
    18. }
    19. public double getPrice() {
    20. return price;
    21. }
    22. public void setPrice(double price) {
    23. this.price = price;
    24. }
    25. @Override
    26. public String getDescription() {
    27. return model + "(" + price + ")";
    28. }
    29. }
    1. package com.team.domain;
    2. public class Printer implements Equipment {
    3. private String name; // 机器型号
    4. private String type; // 机器类型
    5. public Printer() {
    6. super();
    7. }
    8. public Printer(String name, String type) {
    9. super();
    10. this.name = name;
    11. this.type = type;
    12. }
    13. public String getName() {
    14. return name;
    15. }
    16. public void setName(String name) {
    17. this.name = name;
    18. }
    19. public String getType() {
    20. return type;
    21. }
    22. public void setType(String type) {
    23. this.type = type;
    24. }
    25. @Override
    26. public String getDescription() {
    27. return name + "(" + type + ")";
    28. }
    29. }

    四个员工类:

    1. package com.team.domain;
    2. public class Employee {
    3. private int id;
    4. private String name;
    5. private int age;
    6. private double salary;
    7. public Employee() {
    8. super();
    9. }
    10. public Employee(int id, String name, int age, double salary) {
    11. super();
    12. this.id = id;
    13. this.name = name;
    14. this.age = age;
    15. this.salary = salary;
    16. }
    17. public int getId() {
    18. return id;
    19. }
    20. public void setId(int id) {
    21. this.id = id;
    22. }
    23. public String getName() {
    24. return name;
    25. }
    26. public void setName(String name) {
    27. this.name = name;
    28. }
    29. public int getAge() {
    30. return age;
    31. }
    32. public void setAge(int age) {
    33. this.age = age;
    34. }
    35. public double getSalary() {
    36. return salary;
    37. }
    38. public void setSalary(double salary) {
    39. this.salary = salary;
    40. }
    41. public String getDetail() {
    42. return id + "\t" + name + "\t" + age + "\t" + salary;
    43. }
    44. @Override
    45. public String toString() {
    46. return getDetail();
    47. }
    48. }
    1. package com.team.domain;
    2. import com.team.service.Status;
    3. public class Programmer extends Employee {
    4. private int memberId;
    5. private Status status = Status.FREE;
    6. private Equipment equipment;
    7. public Programmer() {
    8. super();
    9. }
    10. public Programmer(int id, String name, int age, double salary, Equipment equipment) {
    11. super(id, name, age, salary);
    12. this.equipment = equipment;
    13. }
    14. public int getMemberId() {
    15. return memberId;
    16. }
    17. public void setMemberId(int memberId) {
    18. this.memberId = memberId;
    19. }
    20. public Status getStatus() {
    21. return status;
    22. }
    23. public void setStatus(Status status) {
    24. this.status = status;
    25. }
    26. public Equipment getEquipment() {
    27. return equipment;
    28. }
    29. public void setEquipment(Equipment equipment) {
    30. this.equipment = equipment;
    31. }
    32. @Override
    33. public String toString() {
    34. return super.toString() + "\t程序员\t" + status + "\t\t\t" + equipment.getDescription();
    35. }
    36. public String getTeamBaseDetails() {
    37. return memberId + "/" + getId() + "\t" + getName() + "\t" + getAge() + "\t" + getSalary();
    38. }
    39. public String getDetailForTeam() {
    40. return getTeamBaseDetails() + "\t程序员";
    41. }
    42. }
    1. package com.team.domain;
    2. public class Designer extends Programmer {
    3. private double bonus;
    4. public Designer() {
    5. super();
    6. }
    7. public Designer(int id, String name, int age, double salary, Equipment equipment, double bonus) {
    8. super(id, name, age, salary,equipment);
    9. this.bonus = bonus;
    10. }
    11. public double getBonus() {
    12. return bonus;
    13. }
    14. public void setBonus(double bonus) {
    15. this.bonus = bonus;
    16. }
    17. @Override
    18. public String toString() {
    19. return super.getDetail() + "\t设计师\t" + getStatus() + "\t" + bonus + "\t\t" + getEquipment().getDescription();
    20. }
    21. @Override
    22. public String getDetailForTeam() {
    23. return getTeamBaseDetails() + "\t设计师" + "\t" + bonus;
    24. }
    25. }
    1. package com.team.domain;
    2. public class Architect extends Designer {
    3. private int stock;
    4. public Architect() {
    5. super();
    6. }
    7. public Architect(int id, String name, int age, double salary, Equipment equipment, double bonus, int stock) {
    8. super(id, name, age, salary, equipment, bonus);
    9. this.stock = stock;
    10. }
    11. public int getStock() {
    12. return stock;
    13. }
    14. public void setStock(int stock) {
    15. this.stock = stock;
    16. }
    17. @Override
    18. public String toString() {
    19. return super.getDetail() + "\t架构师\t" + getStatus() + "\t" + getBonus() + "\t" + stock + "\t"
    20. + getEquipment().getDescription();
    21. }
    22. @Override
    23. public String getDetailForTeam() {
    24. return getTeamBaseDetails() + "\t架构师\t" + getBonus() + "\t" + stock;
    25. }
    26. }

    services包下:

    状态类:

    1. package com.team.service;
    2. /**
    3. *
    4. * @Description 表示员工的状态
    5. * @author Alkaid Email:123456@qq.com
    6. * @version
    7. * @date 2022年8月8日下午4:39:35
    8. *
    9. */
    10. public class Status {
    11. private final String NAME;
    12. private Status(String name) {
    13. this.NAME = name;
    14. }
    15. public static final Status FREE = new Status("FREE");
    16. public static final Status BUSY = new Status("BUSY");
    17. public static final Status VOCATION = new Status("VOCATION");
    18. public String getNAME() {
    19. return NAME;
    20. }
    21. @Override
    22. public String toString() {
    23. return NAME;
    24. }
    25. }

    自定义异常类:

    1. package com.team.service;
    2. public class TeamException extends Exception {
    3. static final long serialVersionUID = -3387516993124229948L;
    4. public TeamException() {
    5. }
    6. public TeamException(String msg) {
    7. super(msg);
    8. }
    9. }

    数据封装类:

    1. package com.team.service;
    2. import java.util.Iterator;
    3. import com.team.domain.Architect;
    4. import com.team.domain.Designer;
    5. import com.team.domain.Employee;
    6. import com.team.domain.Equipment;
    7. import com.team.domain.NoteBook;
    8. import com.team.domain.PC;
    9. import com.team.domain.Printer;
    10. import com.team.domain.Programmer;
    11. /**
    12. *
    13. * @Description 负责将Data中的数据封装到Employee[]数组中,同时提供相关操作Employee[]的方法。
    14. * @author Alkaid Email:123456@qq.com
    15. * @version v1.0
    16. * @date 2022年8月8日下午5:16:44
    17. *
    18. */
    19. public class NameListService {
    20. private Employee[] employees;
    21. public NameListService() {
    22. // 根据项目提供的Data类构建相应大小的employees数组
    23. // 再根据Data类中的数据构建不同的对象,包括Employee、Programmer、Designer和Architect对象,以及相关联的Equipment子类的对象
    24. // 将对象存于数组中
    25. employees = new Employee[Data.EMPLOYEES.length];
    26. for (int i = 0; i < Data.EMPLOYEES.length; i++) {
    27. // 获取员工的类型
    28. int type = Integer.parseInt(Data.EMPLOYEES[i][0]);
    29. // 获取EMPLOYEE的4个基本信息
    30. int id = Integer.parseInt(Data.EMPLOYEES[i][1]);
    31. String name = Data.EMPLOYEES[i][2];
    32. int age = Integer.parseInt(Data.EMPLOYEES[i][3]);
    33. double salary = Double.parseDouble(Data.EMPLOYEES[i][4]);
    34. Equipment equipment;
    35. double bonus;
    36. switch (type) {
    37. case Data.EMPLOYEE:
    38. employees[i] = new Employee(id, name, age, salary);
    39. break;
    40. case Data.PROGRAMMER:
    41. equipment = createEquipment(i);
    42. employees[i] = new Programmer(id, name, age, salary, equipment);
    43. break;
    44. case Data.DESIGNER:
    45. equipment = createEquipment(i);
    46. bonus = Double.parseDouble(Data.EMPLOYEES[i][5]);
    47. employees[i] = new Designer(id, name, age, salary, equipment, bonus);
    48. break;
    49. case Data.ARCHITECT:
    50. equipment = createEquipment(i);
    51. bonus = Double.parseDouble(Data.EMPLOYEES[i][5]);
    52. int stock = Integer.parseInt(Data.EMPLOYEES[i][6]);
    53. employees[i] = new Architect(id, name, age, salary, equipment, bonus, stock);
    54. break;
    55. }
    56. }
    57. }
    58. /**
    59. *
    60. * @Description 指定index上的员工的设备
    61. * @author Alkaid
    62. * @date 2022年8月8日下午7:25:42
    63. * @param i
    64. * @return
    65. */
    66. private Equipment createEquipment(int index) {
    67. int key = Integer.parseInt(Data.EQIPMENTS[index][0]);
    68. String modelOrname = Data.EQIPMENTS[index][1];
    69. switch (key) {
    70. case Data.PC:
    71. String display = Data.EQIPMENTS[index][2];
    72. return new PC(modelOrname, display);
    73. case Data.NOTEBOOK:
    74. double price = Double.parseDouble(Data.EQIPMENTS[index][2]);
    75. return new NoteBook(modelOrname, price);
    76. case Data.PRINTER:
    77. String type = Data.EQIPMENTS[index][2];
    78. return new Printer(modelOrname, type);
    79. }
    80. return null;
    81. }
    82. /**
    83. *
    84. * @Description 获取当前所有员工
    85. * @author Alkaid
    86. * @date 2022年8月8日下午8:39:19
    87. * @return 包含所有员工对象的数组
    88. */
    89. public Employee[] getAllEmployees() {
    90. return employees;
    91. }
    92. /**
    93. *
    94. * @Description 获取指定ID的员工对象。
    95. * @author Alkaid
    96. * @date 2022年8月8日下午8:40:01
    97. * @param id 指定员工的ID
    98. * @return 指定员工对象
    99. */
    100. public Employee getEmployee(int id) throws TeamException{
    101. for (int i = 0; i < employees.length; i++) {
    102. if(employees[i].getId() == id) {
    103. return employees[i];
    104. }
    105. }
    106. throw new TeamException("找不到指定的员工");
    107. }
    108. }

    成员管理:

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

    view包:

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

  • 相关阅读:
    曝 15 寸 iPad 或将变身 Mac?谷歌:大屏设备应具备智能手机体验
    C++中只能有一个实例的单例类
    软件测试之性能测试面试题合集(含答案分析细节)
    Python 多线程、线程池、进程池
    完整记录一下Web前端直传阿里OSS大文件+采用后端临时授权传stsToken的方式
    (刘二大人)PyTorch深度学习实践-卷积网络(基础篇)
    总结 MyBatis 的XML实现方法(使用XML使用实现数据的增删改查操作)
    瑞吉外卖实战项目全攻略——第六天
    快速构建页面结构的 3D Visualization
    局部和全局预编译
  • 原文地址:https://blog.csdn.net/m0_56413004/article/details/126217362