public class Test {
public static void main(String[] args) {
Collection<Students> list = new ArrayList<>();
list.add(new Students("老王", 59.05, 70, 150));
list.add(new Students("老宋", 100, 59.07, 90));
list.add(new Students("小马", 60, 100, 59.06));
list.add(new Students("小慧", 80, 80, 8));
for (Students students : list) {
System.out.println(students);
}
//
System.out.println("请选择你要改变成绩的学生姓名");
String reset = new Scanner(System.in).next();
Students look = new Students();
//
Collection<String> name_tatle = new ArrayList<>();
for (Students students : list) {
name_tatle.add(students.getName());
}
//
String sure = (name_tatle.contains(reset)) ? "已找到需要查找的学生" : "没有找到要查找的学生";
System.out.println(sure);
//
if (name_tatle.contains(reset)) {
for (Students students : list) {
if (reset.equals(students.getName())) {
look = students;
System.out.println(look);
}
}
System.out.println("请选择你要改变什么科目的成绩");
String key = new Scanner(System.in).next();
double last;
switch (key) {
case "英语":
System.out.println("请输入你要改变的成绩");
last = new Scanner(System.in).nextDouble();
look.setEnglish_score(last);
break;
case "数学":
System.out.println("请输入你要改变的成绩");
last = new Scanner(System.in).nextDouble();
look.setMath_score(last);
break;
case "java":
System.out.println("请输入你要改变的成绩");
last = new Scanner(System.in).nextDouble();
look.setJava_score(last);
break;
default:
System.out.println("没有你要查找的科目");
break;
}
for (Students students : list) {
System.out.println(students);
}
}
}
}