public static void main(String[] args) {
System.out.println("****************************************");
System.out.println("* *");
System.out.println("* *");
System.out.println("* 欢迎你来到0912基础班 *");
System.out.println("* *");
System.out.println("* *");
System.out.println("****************************************");
Collection<Student> c = new ArrayList<>();
Scanner sc = new Scanner(System.in);
while(true){
System.out.println(" 请选择功能 : 注册(A) 登陆(B)");
String s = sc.nextLine();
if("a".equalsIgnoreCase(s)){
System.out.println("请输入注册id和用户名,格式为:id-name");
String[] arr1 = sc.nextLine().split("-");
System.out.println("注册成功,目前的用户有:");
c.add(new Student(Integer.parseInt(arr1[0]),arr1[1]));
Iterator<Student> it = c.iterator();
while(it.hasNext()){
System.out.println(" " + it.next());
}
}else if ("b".equalsIgnoreCase(s)){
System.out.println("请输入登陆id和用户名,格式为:id-name");
String[] arr2 = sc.nextLine().split("-");
Student temp = new Student(Integer.parseInt(arr2[0]),arr2[1]);
if(c.contains(temp)){
System.out.println("登陆成功");
break;
}else{
System.out.println("登陆失败");
}
}
}
}
} |
|