import csci130.*;
public class Driver {
public static void main(String args[]){
Encryption pass = new Encryption();
System.out.println("Please enter a password:");
String name = KeyboardReader.readLine();
while (true) {
if (isValidLength(name)) {
break;
}
System.out.println("Your entered password was not long enough.");
}
System.out.println("Encrypted Password: " + pass.encrypt(name));
System.out.println("Decrypted Password: " + pass.decrypt(name));
}
}
boolean isValidLength (String password) {
if (password.length()>minLength) {
return true;
} else {
return false;
}
}
想知道如何让循环工作,以便如果长度不够长,我可以让用户重新输入长度?现在当我编译它会说密码不够长,但不会让他们重新输入有效密码。有什么建议么?