Last active
May 18, 2018 12:54
-
-
Save ClassCubeGists/62424822be3a46776975f2d95f858822 to your computer and use it in GitHub Desktop.
CodeWordChecker solution - AP 2018 FRQ - https://clsc.be/25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CodeWordChecker implements StringChecker { | |
private int min; | |
private int max; | |
private String no; | |
public CodeWordChecker(int mi, int ma, String n) { | |
min = mi; | |
max = ma; | |
no = n; | |
} | |
public CodeWordChecker(String n) { | |
this(6, 20, n); | |
} | |
public boolean isValid(String str) { | |
return str.length() >= min && str.length() <= max && str.indexOf(no) == -1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface StringChecker { | |
/** Returns true if str is valid */ | |
public boolean isValid(String str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment