Melden Sie sich in Java mit 3 ATTEPMTPS an
private void executeLogin() {
String userNameStr = userNameTF.getText();
String passWordStr = passWordTF.getText();
int totalAttempts = 3;
while (totalAttempts != 0) {
if (userNameStr == "temp" && passWordStr == "pass") {
System.out.println("Login Correct!");
return;
} else {
System.out.println("Incorrect Login");
totalAttempts--;
System.out.println(totalAttempts);
}
}
if (totalAttempts == 0) {
System.out.println("Maximum number of attempts exceeded");
}
}
Fernandez, Jasmine M.