复制程式
public class Test{
public static void main(String[] args) throws Exception{
Test t = new Test();
String stPassword = "0123";
int iTryTime=0,iTryLimit=3;
boolean bSuccessLogin = false;
java.io.BufferedReader input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
System.out.print("user login..\r\n");
do{
System.out.print("please enter password:");
String stTemp = input.readLine();
if(stTemp==null || !stTemp.equals(stPassword)){
iTryTime++;
System.out.print("error password, access denied!\r\n");
}
else{
bSuccessLogin = true;
break;
}
}while(iTryTime<iTryLimit);
if(bSuccessLogin){
System.out.print("\r\nlogin success.");
}
else{
System.out.print("\r\nlogin fail.");
}
}
}
我又害了一个学生