// 仅供参考
System.out.println("添加学生信息到普通班级:");
System.out.print("请输入要添加的班级名称:");
String strClass2 = sc.next();
pBan = school.searchByName(strClass2);
if (pBan == null) {
System.out.println("未查询到此班级!!!");
continue;
} else {
System.out.println("请输入要添加的学生个数:");
int input4 = sc.nextInt();
for (int i = 1; i <= input4; i++) {
System.out.println("请输入第" + i + "个学生信息");
System.out.println("请输入要添加的学生的id:");
String strId2 = sc.next();
student = mainBan.searchStudentByNum(strId2);
if (student != null) {
school.searchByName(strClass2).addStudent(student);
} else {
System.out.println("该学生信息在主学生列表中不存在,请输入学生的其它信息!");
System.out.println("请输入要添加的学生姓名:");
String strName2 = sc.next();
student = new Student(strId2, strName2);
mainBan.addStudent(student);
mainBan.displayAllStudent();
continue;
2020-07-24 23:21:51
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星