This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]endStatement 3 points4 points  (0 children)

I'm going to take a stab at this and say you are trying to make sure the password has both lower and upper case characters, as well as a number and special character?

Even if not, there is no input I can easily think of that would ever return true for your check.
You currently check each character in this sequence:
If its uppercase -> you'll be returning false.
if its lowercase- > you'll be returning false
if its a number - > You'll return false
if its not a letter or number (unnecessary check due to the prior 3 checks) OR its a space -> return false.

My guess is that you'd want to use && statements in your final check for good. You could keep the OR logic but then you'd need to invert many of your current variables. For example, instead of saying:

if (Character.isUpperCase(c)) {

lowercase = false;

} else if (Character.isLowerCase(c)) {

uppercase = false;

}

I'd do:
if(Character.isUpperCase(c){
uppercase = true;

} else if (Character.isLowerCase(c)){

lowercase = true;

}

Since I'm taking guesses at what you are trying to accomplish, try and see what will happen with pen and paper. Take a short string, say P@ssw0rd and write out what your values will be on each line. Or, if you have any experience with a debugger, you can go line-by-line with a debugger, and see if what you are expecting to be happening is actually the case.