Browse Source

Pwcheckerclass

master
drddro 1 year ago
parent
commit
b228366702
2 changed files with 16 additions and 6 deletions
  1. 10
    6
      src/PasswordChecker.java
  2. 6
    0
      src/Validation.java

+ 10
- 6
src/PasswordChecker.java View File

@@ -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
- 0
src/Validation.java View File

@@ -0,0 +1,6 @@
public interface Validation {

boolean pwLength(String pw);
boolean pwContainsNum(String pw);
boolean pwContainsSpecial(String pw);
}

Loading…
Cancel
Save