Pwcheckerclass
This commit is contained in:
parent
169543139f
commit
b228366702
@ -1,12 +1,16 @@
|
||||
public class PasswordChecker {
|
||||
public class PasswordChecker implements Validation{
|
||||
|
||||
private final static int pwMinLength = 6;
|
||||
private final int pwMinLength;
|
||||
|
||||
public static boolean pwLength(String password){
|
||||
public PasswordChecker(int minPwSize){
|
||||
pwMinLength = minPwSize;
|
||||
}
|
||||
|
||||
public boolean pwLength(String password){
|
||||
return password.length() >= pwMinLength;
|
||||
}
|
||||
|
||||
public static boolean pwContainsNum(String password){
|
||||
public boolean pwContainsNum(String password){
|
||||
for (int i = 0; i < password.length(); i++) {
|
||||
if(Character.isDigit(password.charAt(i))){
|
||||
return true;
|
||||
@ -15,11 +19,11 @@ public class PasswordChecker {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean pwContainsSpecialHelper(char c){
|
||||
private boolean pwContainsSpecialHelper(char c){
|
||||
return(!(Character.isDigit(c)|| Character.isLetter(c)));
|
||||
}
|
||||
|
||||
public static boolean pwContainsSpecial(String password){
|
||||
public boolean pwContainsSpecial(String password){
|
||||
for (int i = 0; i < password.length(); i++) {
|
||||
if(pwContainsSpecialHelper(password.charAt(i))){
|
||||
return true;
|
||||
|
6
src/Validation.java
Normal file
6
src/Validation.java
Normal file
@ -0,0 +1,6 @@
|
||||
public interface Validation {
|
||||
|
||||
boolean pwLength(String pw);
|
||||
boolean pwContainsNum(String pw);
|
||||
boolean pwContainsSpecial(String pw);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user