ggadget6

AP CS A 2018 FRQ #3

May 17th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public class CodeWordChecker implements StringChecker
  2. {
  3. private int min;
  4. private int max;
  5. private String notOccur;
  6.  
  7. public CodeWordChecker(int min, int max, String notOccur)
  8. {
  9. this.min = min;
  10. this.max = max;
  11. this.notOccur = notOccur;
  12. }
  13. public CodeWordChecker(String notOccur)
  14. {
  15. min = 6;
  16. max = 20;
  17. this.notOccur = notOccur;
  18. }
  19. public boolean isValid(String str)
  20. {
  21. return (str.length() >= min) && (str.length <= max) && (str.indexOf(notOccur) == -1);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment