Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

login in java with 3 attepmtps

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");
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #login #java #attepmtps
ADD COMMENT
Topic
Name
3+1 =