求 JAVA数组中用户名与密码该怎么匹配?
privatebooleanlogin(){this.allUsers=newUserInfo[5];for(inti=0;i<this.allUsers.length;...
private boolean login() {
this.allUsers = new UserInfo[5];
for(int i = 0; i < this.allUsers.length; i++){
this.allUsers[i] = new UserInfo();
this.allUsers[i].setUsername("zhang" + i);
this.allUsers[i].setPassword("12345" + i);
this.allUsers[i].setAccount((i + 1) * 10000.0f);
}
Scanner scan = new Scanner(System.in);
System.out.println("请输入您的用户名:");
String inputName = scan.next();
System.out.println("请输入您的密码:");
String inputPwd = scan.next();
if (inputName.equals(该怎么填?)
&& inputPwd.equals(该怎么填)) {
System.out.println("欢迎你," + inputName);
return true;
}
System.out.println("用户名、密码有误!请查证!");
return false;
} 展开
this.allUsers = new UserInfo[5];
for(int i = 0; i < this.allUsers.length; i++){
this.allUsers[i] = new UserInfo();
this.allUsers[i].setUsername("zhang" + i);
this.allUsers[i].setPassword("12345" + i);
this.allUsers[i].setAccount((i + 1) * 10000.0f);
}
Scanner scan = new Scanner(System.in);
System.out.println("请输入您的用户名:");
String inputName = scan.next();
System.out.println("请输入您的密码:");
String inputPwd = scan.next();
if (inputName.equals(该怎么填?)
&& inputPwd.equals(该怎么填)) {
System.out.println("欢迎你," + inputName);
return true;
}
System.out.println("用户名、密码有误!请查证!");
return false;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询