void ReviseCode(){
Scanner sr=new Scanner(System.in);
System.out.println("第一次使用请修改密码 请输入原始密码");
int Code = sr.nextInt();
if(Code==originalCode){
System.out.println("同意修改密码,请输入你的新密码");
Scanner sr1=new Scanner(System.in);
int newCode=sr1.nextInt();
System.out.println("密码修改成功");
}
else
System.out.println("密码错误,你无权修改密码");
}
void OpenDoor(){
System.out.println("请输入密码");
Scanner sr2=new Scanner(System.in);
int entryCode=sr2.nextInt();
if(entryCode==newCode){
System.out.println("门开了,请进");
}
else
System.out.println("密码错误");
}为的是让新修改的密码newCode跟entryCode对比,相等就同意开门。而newCode是在类ReviseCode输入的修改密码。
添加回答
举报
0/150
提交
取消