Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. /* Bad Word Checker
  2. Tests a word against a list of words
  3. Better put: tests a string against an array of strings
  4. Steve Lambert April 26, 2017
  5. */
  6.  
  7. // VARIABLES
  8.  
  9. String filename = "wordlist.txt"; // file with words to check against
  10. String[] lines; // array of the lines in the file
  11. String testword = "you"; // word you are testing
  12.  
  13.  
  14. void setup() {
  15. size(250,250);
  16. smooth();
  17.  
  18. // load the file into an array{
  19. lines = loadStrings(filename);
  20.  
  21. // Launch info!
  22. // how many lines are in that text file?
  23. println("there are " + lines.length + " lines");
  24. // show me what's in the text file
  25. for (int i = 0 ; i < lines.length; i++) {
  26. println(lines[i]);
  27. }
  28. // Launch confirmation
  29. println("PROGRAM IS LAUNCHED!");
  30. println("");
  31.  
  32. } // end setup, let's get started.
  33.  
  34.  
  35.  
  36. void draw() {
  37.  
  38.  
  39. if (frameCount % 100 == 0){ // Every 100 frames...
  40.  
  41. for (int i = 0 ; i < lines.length; i++) {
  42.  
  43. if(lines[i].equals(testword)){
  44. println("We have a match! " + lines[i] + " = " + testword);
  45. } else {
  46. println(lines[i] + " != " + testword);
  47. } // end if
  48.  
  49. } // end for
  50. println("");
  51. } // end modulo if
  52.  
  53. } // end draw
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement