-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.java
39 lines (36 loc) · 1.32 KB
/
debug.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package day4;
class Debug {
public boolean strongPasswordCheckerII(String password) {
boolean hasDigit = false;
boolean hasLower = false;
boolean hasUpper = false;
boolean hasSpecial = false;
boolean has8 = false;
boolean hasSame = true;
for (int i = 0; i < password.length(); i++) {
char c = password.charAt(i);
if (Character.isDigit(c)) {
hasDigit = true;
} else if (Character.isLowerCase(c)) {
hasLower = true;
} else if (Character.isUpperCase(c)) {
hasUpper = true;
} else if (c == '!' || c == '@' || c == '#' || c == '$' || c == '%' || c == '^' || c == '&' || c == '*'
|| c == '(' || c == ')' || c == '-' || c == '+') {
hasSpecial = true;
}
if (password.length() >= 8) {
has8 = true;
}
if (i > 0 && password.charAt(i) == password.charAt(i - 1)) {
hasSame = false;
}
}
return hasDigit && hasLower && hasUpper && hasSpecial && has8 && hasSame;
}
public static void main(String[] args) {
Debug d = new Debug();
String password = "11A!A!Aa";
System.out.println(d.strongPasswordCheckerII(password));
}
}