Search
 
SCRIPT & CODE EXAMPLE
 

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");
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: substring in java 
Java :: how many return values can a method hava java 
Java :: java initialize dynamic array of boolean 
Java :: Accept Integer only in if else statement 
Java :: data input stream using while loop 
Java :: We would like to make a member of a class can access in all subclasses regardless of what package the subclass is in. Which one of the following keywords would achieve this? 
Java :: subtract two variables in java 
Java :: 2d matrix 
Java :: private void loadmaze(string mazefile) 
Java :: Fomating .json 
Java :: password = sdf345 password.isalpha() java 
Java :: get string match percentage java 
Java :: Java (HotSpot 12) sample 
Java :: last element array java 
Java :: how to know when user is done typing android 
Java :: java yaml unchecked cast 
Java :: constraints in Grails 
Java :: cannot find symbol final TextView textView = root.findViewById(R.id.text_home); 
Java :: custom class level annotation in spring 
Java :: Uri/Beecrowd problem no - 1146 solution in Java 
Java :: alternatives jdk1.8 rhel6 
Java :: create object of hashMap 
Java :: file with line numbers inserted java 
Java :: JSP Convertir Int a String 
Java :: Repeat execution of function infini android studio 
Java :: merge sort algorithm in java short answer 
Java :: how to fetch email and get there body content in spring boot 
Java :: darkhub 
Java :: Java (sun-jdk-1.8.0_51) sample 
Java :: java window always on top 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =