, , , . , . . ( , , ) :
public static boolean validatePassword(String password) {
int len = password.length();
bool cond1 = len < 8;
if (!cond1) cond1 = len > 20;
if (cond1)
return false;
boolean hasLetters = false;
boolean hasDigits = false;
int i = 0;
while(i < len) {
if (!Character.isLetterOrDigit(password.charAt(i)))
return false;
bool hasDigitsVal = hasDigits;
if (!hasDigitsVal) hasDigitsVal = Character.isDigit(password.charAt(i));
hasDigits = hasDigitsVal
bool hasLettersVal = hasLetters;
if (!hasLettersVal) hasLettersVal = Character.isLetter(password.charAt(i));
hasLetters = hasLettersVal;
i++;
}
bool cond2 = hasDigits;
if (cond2) cond2 = hasLetters;
return cond2;
}
, || && if . , 6 if while! , 7, ?
, . node, . return, return node.
void foo() {
if (cond1) return a;
if (cond2) return b;
return c;
}
, -----val----> EXIT val:
START -> cond1
| |
cond2
| |
return
, "pre-return" node, node:
void foo() {
int val;
if (cond1) {
val= a;
}
else {
if (cond2) {
val= b;
}
else {
val= c;
}
}
return val;
}
:
START -> cond1
| |
cond2
| |
+
, .