}
public void setSalary(double salary) {
this.salary = salary;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public double getSalary() {
return salary;
}
//方法
public String getDetails(){
return id+"t"+name+"t"+" “+age+”tt"+salary;
}
@Override
public String toString() {
return getDetails();
}
}
programmer(程序员类):
package domain;
public class Programmer extends Employee {
private int memberld;//用来记录成员加入开发团队后在团队中的ID
private boolean status = true;//Status是项目中人员的状态,先赋值为true,当添加到团队时为false
public Equipment equipment;
public Programmer(int id, String name, int age, double salary, Equipment equipment) {
super(id,name,age,salary);
this.equipment=equipment;
}
public Programmer(int id, String name, int age, double salary, int memberld, boolean status, Equipment equipment) {
super(id, name, age, salary);
this.equipment = equipment;
}
public Programmer() {
}
public int getMemberId() {
return memberld;
}
public void setMemberId(int memberId) {
this.memberld = 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 + “ttttt” + equipment.getDescription();
}
}
Designer(设计师类):
package domain;
public class Designer extends Programmer{
public double bonus;//奖金
public Designer() {
}
public Designer(int id, String name, int age, double salary, Equipment equipment, double bonus) {
super(id, name, age, salary, equipment);
this.bonus = bonus;
}
public double getBonus() {
return bonus;
}
public void setBonus(double bonus) {
this.bonus = bonus;
}
@Override
public String getDetailsForTeam() {
return getMemberDetails()+"t设计师t"+getBonus();
}
@Override
public String toString() {
return getDetails() + “t设计师t” + getStatus() + “t” +
getBonus() +"ttt" + getEquipment().getDescription();
}
}
Architect(架构师类):
package domain;
public class Architect extends Designer{
public int stock;//公司奖励的股票数量
public Architect(){
}
public Architect(int id, String name, int age, double salary, Equipment equipment, double bonus, int stock) {
super(id, name, age, salary, equipment, bonus);
this.stock = stock;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
@Override
public String getDetailsForTeam() {
return getMemberDetails() + “t架构师t” +
getBonus() + “t” + getStock();
}
@Override
public String toString() {
return getDetails() + “t架构师t” + getStatus() + “t” +
getBonus() + “t” + getStock() + “t” + getEquipment().getDescription();
}
}
接口Equipment(电子设备):
package domain;
public interface Equipment {//电子设备
String getDescription();//类型
}
接口实现类Notebook(笔记本电脑):
package domain;
import view.TSUtility;
public class NoteBook implements Equipment {
public String model;//机器的型号
public double price;//价格
public NoteBook() {
super();
}
public NoteBook(String model, double price) {
super();
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+")";
}
}
接口实现类PC(台式电脑):
package domain;
import view.TSUtility;
public class PC implements Equipment{
public String model;//机器型号
public String display;//显示器名称
public PC() {
super();
}
public PC(String model, String display) {
super();
this.model = model;
this.display = display;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
public PC addPC(){
System.out.println(“请输入你需要配置的台式电脑的型号”);
String model= TSUtility.readKeyBoard(10,false);
System.out.println(“请输入你需要配置的台式电脑的显示屏的名称”);
String display=TSUtility.readKeyBoard(10,false);
System.out.println(“设备添加成功!”);
return new PC(model,display);
}
@Override
public String getDescription() {
return model+"("+display+")";
}
}
接口实现类Printer(打印机):
package domain;
import view.TSUtility;
import java.time.format.TextStyle;
public class Printer implements Equipment{
public String name;
public String type;//机器类型
public Printer() {
}
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+")";
}
}
项目实体类project:
package domain;
import java.util.Arrays;
public class Project {
private int proId;//项目号
private String projectName;//项目名称
private String desName;//项目描述
private Programmer[] team;//开发团队
private String teamName;//开发团队名称
private boolean status=false;//开发状态(true为开发中,false为未开发)
public Project() {
}
public Project(int proId, String projectName, String desName, Programmer[] team, String teamName, boolean status) {
this.proId = proId;
this.projectName = projectName;
this.desName = desName;
this.team = team;
this.teamName = teamName;
this.status = status;
}
public int getProId() {
return proId;
}
public void setProId(int proId) {
this.proId = proId;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getDesName() {
return desName;
}
public void setDesName(String desName) {
this.desName = desName;
}
public Programmer[] getTeam() {
return team;
}
public void setTeam(Programmer[] team) {
this.team = team;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public String des(){
return “Project项目{” +
“proId项目号=” + proId +
“, projectName项目名称=’” + projectName + ‘’’ +
“, desName项目描述=’” + desName + ‘’’ +
“, team开发团队=” + Arrays.toString(team) +
“, teamName开发团队名称=’” + teamName + ‘’’ +
“, status开发团队状态=” + status +
‘}’;
}
@Override
public String toString() {
des();
if (status){
return “项目【” + projectName + “】”+ “---->正在被团队【” + teamName + “】开发中!”;
}else {
return des()+“项目【” + projectName + “】---->”+ “未被开发!”;
}
}
}
2、service包下:
异常类TeamException:
package service;
public class TeamException extends Exception{
public TeamException(){}
public TeamException(String message) {
super(message);
}
}
开发人员管理类NameListService:
package service;
import domain.*;
import view.TSUtility;
import java.util.ArrayList;
public class NameListService {
//装雇员的集合
private static ArrayList employees = new ArrayList();
//添加员工的ID
private int count = 1;
//初始化默认值(代码块)
{
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 NameListService() {
}
public NameListService(ArrayList employees, int count) {
this.employees = employees;
this.count = count;
}
public ArrayList getEmployees() {
return employees;
}
public void setEmployees(ArrayList employees) {
this.employees = employees;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
//得到所有员工数据集合
public ArrayList 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(){
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 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++) {
//动态ID,随着人员删除ID相应变化(内涵:找到索引减一的那个值,此时这个值对应的就是删除ID后,接上来的那个ID,只要将这个ID减一,就能继续升序而不断开)
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(“IDt 姓名t 年龄t 工资t 职位t 状态t 奖金t 股票t 领用设备”);
for (int i = 0; i < employees.size(); i++) {
System.out.println(""+employees.get(i));
}
}
//修改员工信息(姓名,年龄,工资)
public void modifyEmployee(int id){
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()+")(回车直接跳过修改);
String name=TSUtility.readString(4,emp.getName());
System.out.println(“年龄(”+emp.getAge()+")(回车直接跳过修改);
int age=Integer.parseInt(TSUtility.readString(2,emp.getAge()+""));
System.out.println(“工资(”+emp.getSalary()+")(回车直接跳过修改);
double salary=Double.parseDouble(TSUtility.readString(6,emp.getSalary()+""));
emp.setName(name);
emp.setAge(age);
emp.setSalary(salary);
employees.set(i,emp);
flag=true;
}
}
if(flag){
System.out.println(“修改成功!”);
}else {
try {
throw new TeamException(“该员工不存在”);
} catch (TeamException e) {
e.printStackTrace();
}
}
}
}
团队人员管理类Teamservice:
package service;
import domain.Architect;
import domain.Designer;
import domain.Employee;
import domain.Programmer;
public class TeamService {
//静态变量,用来为开发团队新增成员自动生成团队中的唯一ID,即memberId。(提示:应使用增1的方式)
private static int counter = 1;
//开发团队最大成员数,final静态为常量,变量名全大写
private final int MAX_MEMBER = 5;
//数组,程序员数组
Programmer[] team = new Programmer[MAX_MEMBER];
//团队实际人数
private int total = 0;
public TeamService() {
}
public TeamService(int counter, Programmer[] team, int total) {
this.counter = counter;
this.team = team;
this.total = total;
}
public Programmer[] getTeam() {
Programmer[] team = new Programmer[total];
for (int i = 0; i < total; i++) {
team[i] = this.team[i];
}
return team;
}
//初始化当前团队成员数组
public void clearTeam() {
team = new Programmer[MAX_MEMBER];
counter = 1;
total = 0;
this.team = team;
}
//增加团队成员
public void addMember(Employee e) throws TeamException {
if (total >= MAX_MEMBER) {
throw new TeamException(“成员已满,无法添加”);
}
if (!(e instanceof Programmer)) {
throw new TeamException(“该成员不是开发人员,无法添加”);
}
Programmer p = (Programmer) e;
if (isExist§) {
throw new TeamException(“该员工已在本团队中”);
}
if (!(p.getStatus())) {
throw new TeamException(“该员工已是某一团队成员”);
}
//团队中人员要求,至多一位架构师,至多两位设计师,至多三位程序员
int numArchitect = 0;
int numDesigner = 0;
int numProgrammer = 0;
for (int i = 0; i < total; i++) {
if (team[i] instanceof Architect) {
numArchitect++;
} else if (team[i] instanceof Designer) {
numDesigner++;
} else if (team[i] instanceof Programmer) {
numProgrammer++;
}
}
if (p instanceof Architect) {
if (numArchitect >= 1) {
throw new TeamException(“团队中至多只能有一位架构师”);
}
} else if (p instanceof Designer) {
if (numDesigner >= 2) {
throw new TeamException(“团队中至多只能有两位设计师”);
}
} else if (p instanceof Programmer) {
if (numProgrammer >= 3) {
throw new TeamException(“团队中至多只能有三位程序员”);
}
}
//添加到数组
p.setStatus(false);
p.setMemberId(counter++);
team[total++] = p;
}
//判断团队中是否已经存在这个成员
public boolean isExist(Programmer p) {
for (int i = 0; i < total; i++) {
if (team[i].getId() == p.getId()) {
return true;
}
}
return false;
}
//删除指定memberld的成员(已经在团队内的成员)
public void removeMember(int memberld) throws TeamException {
int n = 0;
//找到指定TID(memberld)的员工删除,遍历,找不到报异常
for (; n < total; n++) {
if (team[n].getMemberId() == memberld) {
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;
int a =1;
for(int i =0;i team[i].setMemberId(a++); } } } 项目开发管理类ProjectService: package service; import domain.Programmer; import domain.Project; import view.TSUtility; import java.util.ArrayList; import java.util.Random; public class ProjectService { private ArrayList pro = new ArrayList<>(); private int count = 1; int a = 1; int b = 1; int c = 1; int d = 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 ch = TSUtility.readMenuSelection(); switch (ch) { case ‘1’: Project p1 = new Project(); p1.setProId(count++); p1.setProjectName(“小米官网”); p1.setDesName(“开发完成类似于小米官网的web项目”); if (a == 1) { pro.add(p1); TSUtility.loadSpecialEffects(); System.out.println(“已添加项目:” + p1.getProjectName()); a++; } else { System.out.println(“你添加的项目已经被添加,请添加其他的项目!”); } break; case ‘2’: Project p2 = new Project(); p2.setProId(count++); p2.setProjectName(“公益在线商城”); p2.setDesName(“猫宁Morning公益商城是中国公益性在线电子商城”); if (b == 《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》 【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享 pro.add(p2); TSUtility.loadSpecialEffects(); System.out.println(“已添加项目:” + p2.getProjectName()); b++; } else { System.out.println(“你添加的项目已经被添加,请添加其他的项目!”); } break; case ‘3’: Project p3 = new Project(); p3.setProId(count++); p3.setProjectName(“博客系统”); p3.setDesName(“Java博客系统,让每一个有故事的人更好的表达想法!”); if (c == 1) { pro.add(p3); TSUtility.loadSpecialEffects(); System.out.println(“已添加项目:” + p3.getProjectName()); } else { System.out.println(“你添加的项目已经被添加,请添加其他的项目!”); } break; case ‘4’: Project p4 = new Project(); p4.setProId(count++); p4.setProjectName(“在线协作文档编辑系统”); p4.setDesName(“一个很常用的功能,适合小组内的文档编辑。”); if (d == 1) { pro.add(p4); TSUtility.loadSpecialEffects(); System.out.println(“已添加项目:” + p4.getProjectName()); } 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(6, false); //分配项目随机 if (team.length!=0) { Random r = new Random(); int RandomNum = r.nextInt(pro.size()); Project project = this.pro.get(RandomNum); if (!(project.equals(null))) { project.setTeamName(teamName); project.setTeam(team); project.setStatus(true); pro.set(RandomNum, project); } } } //查看项目当前状态 public void showPro() throws InterruptedException { TSUtility.loadSpecialEffects(); if (pro.size() == 0) { System.out.println(“当前没有项目,请添加项目!!!”); } for (int i = 0; i < pro.size(); i++) { System.out.println(pro.get(i)); } } //删除选择的项目 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);//动态ID改变 } flag = true; } } else { throw new TeamException(“当前项目正在被开发,无法删除!”); } } if (flag) { System.out.println(“删除成功!”); count–; } else { try { throw new TeamException(“该项目不存在!”); } catch (TeamException e) { e.printStackTrace(); } } } //遍历集合所有元素得到所有数据 public ArrayList getAllPro() { for (int i = 0; i < pro.size(); i++) { System.out.println(pro.get(i)); } return pro; } } 3、view包下: 用户登录/注册界面LoginView: package view; import java.util.Scanner; @SuppressWarnings(“all”) public class LoginView { //需要初始化值,让String类型的默认初始化不是为null; private String userName="";//用户名 private String password="";//登录密码 //用户注册信息 public void register() throws InterruptedException { TSUtility.loadSpecialEffects(); System.out.println(“开始注册…”); Scanner sc = new Scanner(System.in); System.out.println(“请输入你要注册的账户名称(名称不大于四位):”); String userName = TSUtility.readKeyBoard(4, false); this.userName=userName; System.out.println(“请输入你的登录密码(位数不大于八位):”); String password = TSUtility.readKeyBoard(8, false); this.password=password; System.out.println(“注册成功,请重新登录。”); } //用户登录 public void Login() throws InterruptedException { //登录失败的限制次数 int count = 5; boolean flag = true; //登录界面的循环 while (flag) { System.out.println("********************"); System.out.println("*** <登录界面> ***"); 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(“未检测到你的账号信息,请重新输入或注册”); register(); } 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 revise() throws InterruptedException { boolean flag = true; //修改界面的循环 while (flag) { 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(不修改,退出)”); Scanner sc = new Scanner(System.in); String num = sc.next(); if (num.equals(“1”)) { System.out.println(“请输入你需要修改的新账户名称:”); String userName = TSUtility.readKeyBoard(4, false); this.userName = userName; System.out.println(“修改成功!”); } else if (num.equals(“2”)) { System.out.println(“请输入你需要修改的新账户密码:”); String password = TSUtility.readKeyBoard(8, false); this.password = password; System.out.println(“修改成功!”); } else if (num.equals(“3”)) { System.out.println(“请输入你需要修改的新账户名称:”); String userName = TSUtility.readKeyBoard(4, false); this.userName = userName; System.out.println(“请输入你需要修改的新密码:”); String password = TSUtility.readKeyBoard(8, false); this.password = password; System.out.println(“修改成功!”); } else if (num.equals(“4”)) { System.out.println(“你确定退出吗?Y/N”); char ch = TSUtility.readConfirmSelection(); if (ch == ‘Y’) { System.out.println(“正在退出…”); TSUtility.loadSpecialEffects(); flag = false; } } else { System.out.println(“输入错误!请输入“1”或者“2”或者“3”或者“4”:”); } } } } 团队修改界面Teamview: package view; import com.sun.org.apache.xpath.internal.objects.XNumber; 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(); private ArrayList //团队管理 public void enterMainMenu() { boolean flag = true; char key = ‘0’; do { if (key != ‘1’) { listAllEmployees(); } System.out.println(“1-团队列表 2-添加团队成员 3-删除团队成员 4-退出 请选择(1-4):”); key = TSUtility.readMenuSelection(); System.out.println(); switch (key) { case ‘1’: listTeam(); break; case ‘2’: addMember(); break; case ‘3’: deleteMember(); break; case ‘4’: System.out.println(“请确认是否退出?y/n”); char ch = TSUtility.readConfirmSelection(); if (ch == ‘Y’) { team.add(teamSvc.getTeam());//返回数组 teamSvc.clearTeam();//初始化当前团队成员数组 flag = false; } break; default: System.out.println(“你输入的信息有误,请重新输入!”); break; } } while (flag); } //显示查看所有团队成员 private void listAllEmployees() { System.out.println("n-------------------------------开发团队调度软件--------------------------------n"); ArrayList emps = listSvc.getAllEmployees(); if (emps.size() == 0) { System.out.println(“没有客户记录存在!”); } else { System.out.println(“IDt 姓名t年龄t 工资t 职位t 状态t 奖金t 股票t 领用设备”); } for (Employee e : emps) { System.out.println("" + e); } System.out.println("-------------------------------------------------------------------------------"); } //显示开发团队成员列表 private void listTeam() { System.out.println("n--------------------团队成员列表---------------------n"); Programmer[] team = teamSvc.getTeam(); if (team.length == 0) { System.out.println(“开发团队目前没有成员!”); } else { System.out.println(“TID/IDt姓名t 年龄t 工资t 职位t 奖金t 股票”); } //增强for循环 System.out.println("-----------------------------------------------------"); for (Programmer p : team) { System.out.println(" " + p.getDetailsForTeam()); } System.out.println("-----------------------------------------------------"); } //添加成员到团队 private void addMember() { 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(); } //删除团队中指定ID的人员 private void deleteMember() { System.out.println("---------------------删除成员---------------------"); listTeam(); if (teamSvc.getTeam().length != 0) { System.out.print(“请输入要删除员工的TID:”); int TID = TSUtility.readInt(); if (TID < 1) { try { throw new TeamException(“不存在该成员的TID”); } catch (TeamException e) { // e.printStackTrace(); System.out.println(e.getMessage()); } } System.out.println(“请问是否继续删除?(y/n)”); char ch = TSUtility.readConfirmSelection(); if (ch == ‘n’) { return; } try { teamSvc.removeMember(TID); System.out.println(“删除成功”); } catch (TeamException e) { System.out.println(“删除失败,原因:” + e.getMessage()); } // 按回车键继续… TSUtility.readReturn(); } } // 加入团队并得到更多的团队 public ArrayList boolean flag = true; char key = 0; do { System.out.println("※※※※※※※※※※※"); System.out.println("※ 团队调度界面 ※"); System.out.println("※※※※※※※※※※※"); System.out.print(“1-添加团队 2-查看团队 3-删除团队 4-退出 请选择(1-4):”); key = TSUtility.readMenuSelection(); System.out.println(); switch (key) { case ‘1’: enterMainMenu(); break; case ‘2’: System.out.println("-------团队列表--------"); 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.readInt(); if (num <= team.size()) { System.out.print(“确认是否删除(Y/N):”); char de = TSUtility.readConfirmSelection(); if (de == ‘Y’) { team.remove(num - 1); } else { System.out.println(“请考虑清楚!”); } } else { System.out.println(“没有该团队,请正常输入!” + “目前团队只有” + team.size() + “个”); } } break; case ‘4’: System.out.print(“确认是否退出(Y/N):”); char yn = TSUtility.readConfirmSelection(); if (yn == ‘Y’) { flag = false; } break; default: System.out.println(“你输入的信息有误,请重新输入!”); break; } } while (flag); return team; } } 最终集合展示模块(运行主界面)IndexView: package view; import domain.Programmer; import service.NameListService; import service.ProjectService; import service.TeamException; import java.util.ArrayList; public class IndexView { private final static LoginView loginView = new LoginView(); private final static NameListService nameListService = new NameListService(); private final static TeamView teamView = new TeamView(); private final static ProjectService projectService = new ProjectService(); private ArrayList public void Menu() throws TeamException { boolean flag = 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 { loginView.Login(); } catch (InterruptedException e) { e.printStackTrace(); } 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.readMenuSelectionPro(); switch (key) { case ‘1’: try { loginView.revise(); } catch (InterruptedException e) { System.out.println(e.getMessage()); // e.printStackTrace(); } break; case ‘2’: try { nameListService.showEmployee(); } catch (InterruptedException e) { // e.printStackTrace(); System.out.println(e.getMessage()); } boolean flagSec = 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.readMenuSelectionPro(); switch (keySec) { case ‘1’: nameListService.addEmployee(); break; case ‘2’: try { nameListService.showEmployee(); } catch (InterruptedException e) { // e.printStackTrace(); System.out.println(e.getMessage()); } break; case ‘3’: System.out.println(“请输入需要修改的员工id:”); int j = TSUtility.readInt(); nameListService.modifyEmployee(j); break; case ‘4’: System.out.println(“请输入需要删除的员工id:”); int i = TSUtility.readInt(); try { nameListService.delEmployee(i); } catch (TeamException e) { // e.printStackTrace(); System.out.println(e.getMessage()); } break; case ‘5’: System.out.println(“请确认是否退出:(Y/N)”); char ch = TSUtility.readConfirmSelection(); if (ch == ‘Y’) { flagSec = false; } break; default: System.out.println(“输入有误,请重新输入!”); break; } } while (flagSec); break; case ‘3’: manyTeam = teamView.getManyTeam(); break; case ‘4’: boolean flagThr = 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.readMenuSelectionPro(); switch (keyThr) { case ‘1’: try { projectService.addProject(); } catch (InterruptedException e) { // e.printStackTrace(); System.out.println(e.getMessage()); } break; case ‘2’: for (Programmer[] pro : manyTeam) { 欢迎分享,转载请注明来源:内存溢出
评论列表(0条)