Skip to content

Instantly share code, notes, and snippets.

@ClassCubeGists
Last active May 18, 2018 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClassCubeGists/62424822be3a46776975f2d95f858822 to your computer and use it in GitHub Desktop.
Save ClassCubeGists/62424822be3a46776975f2d95f858822 to your computer and use it in GitHub Desktop.
CodeWordChecker solution - AP 2018 FRQ - https://clsc.be/25
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;
}
}
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