public static void addStudent(ArrayList<Student> list) {
Scanner sc = new Scanner(System.in);
String sid;
while (true) {
System.out.println("请输入学生学号");
sid = sc.nextLine();
boolean falg = isUsed(list, sid);
if (falg) {
System.out.println("你输入的学号已存在,请重新输入");
} else {
break;
}
}
System.out.println("请输入学生姓名");
String name = sc.nextLine();
System.out.println("请输入学生年龄");
String age = sc.nextLine();
System.out.println("请输入学生所在地");
String address = sc.nextLine();
Student s = new Student();
s.setSid(sid);
s.setName(name);
s.setAge(age);
s.setAddress(address);
list.add(s);
System.out.println("添加学生成功") |
|