package Zuoye229;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
public class Test229 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Map<Integer, Student229> list = new HashMap<>();
// 增加学生
while (true) {
System.out.println("1、增加学生、2显示所以学生、3删除学生、4查找学生、5修改学生、6退出程序");
int a = new Scanner(System.in).nextInt();
switch (a) {
case 1:
System.out.println("请输入学生的学号");
int b1 = new Scanner(System.in).nextInt();
if (!list.containsKey(b1)) {
System.out.println("请输入学生的姓名");
String b2 = new Scanner(System.in).next();
System.out.println("请输入学生的成绩");
int b3 = new Scanner(System.in).nextInt();
Student229 s = new Student229(b2, b3);
list.put(b1, s);
System.out.println("添加成功");
}else {
System.out.println("该学号已经存在添加失败");
}
break;
case 2:
Set<Integer> d6 = list.keySet();
for (Integer integer : d6) {
Student229 st229 = list.get(integer);
System.out.println("学号" + integer + "," + st229);
}
break;
case 3:
System.out.println("请输入要删除学生的学号");
int b4 = new Scanner(System.in).nextInt();
list.remove(b4);
System.out.println("删除成功");
break;
case 4:
System.out.println("请输入你要查找的学生学号");
int b5 = new Scanner(System.in).nextInt();
Student229 c = list.get(b5);
if (!list.containsKey(b5)) {
System.out.println("你输入的学号不存在查找失败");
} else {
System.out.println("你要查找的学生学号是" + b5 + c);
}
break;
case 5:
System.out.println("请输入你要修改的学生学号");
int b6 = new Scanner(System.in).nextInt();
Student229 c2 = list.get(b6);
if (!list.containsKey(b6)) {
System.out.println("你输入的学号不存在修改失败");
} else {
System.out.println("你要修改的学生是" + b6 + c2);
System.out.println("请输入学生的姓名");
String i2 = new Scanner(System.in).next();
System.out.println("请输入学生的成绩");
int i3 = new Scanner(System.in).nextInt();
Student229 s2 = new Student229(i2, i3);
list.put(b6, s2);
System.out.println("修改成功");
}
break;
case 6:
return;
default:
System.out.println("你输入的数字不在范围内");
;
}
}
}
}