public static void addstudent(ArrayList<Student> array){
int q=0;
Scanner sc = new Scanner(System.in);
System.out.println("请输入学号");
String sid =sc.nextLine();
for(int i=0;i<array.size();i++){
Student s= array.get(i);
if(s.getSid().equals(sid)){
System.out.println("输入的学号有重复,请检查后重新输入!");
q++;
break;
}
}
if(q==0){
System.out.println("请输入姓名");
String name =sc.nextLine();
System.out.println("请输入年龄");
String age =sc.nextLine();
System.out.println("请输入性别");
String sex =sc.nextLine();
Student s = new Student();
s.setSid(sid);
s.setSex(sex);
s.setName(name);
s.setAge(age);
array.add(s);
System.out.println("添加学生成功!");
}
}