Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Bad Word Checker
- Tests a word against a list of words
- Better put: tests a string against an array of strings
- Steve Lambert April 26, 2017
- */
- // VARIABLES
- String filename = "wordlist.txt"; // file with words to check against
- String[] lines; // array of the lines in the file
- String testword = "you"; // word you are testing
- void setup() {
- size(250,250);
- smooth();
- // load the file into an array{
- lines = loadStrings(filename);
- // Launch info!
- // how many lines are in that text file?
- println("there are " + lines.length + " lines");
- // show me what's in the text file
- for (int i = 0 ; i < lines.length; i++) {
- println(lines[i]);
- }
- // Launch confirmation
- println("PROGRAM IS LAUNCHED!");
- println("");
- } // end setup, let's get started.
- void draw() {
- if (frameCount % 100 == 0){ // Every 100 frames...
- for (int i = 0 ; i < lines.length; i++) {
- if(lines[i].equals(testword)){
- println("We have a match! " + lines[i] + " = " + testword);
- } else {
- println(lines[i] + " != " + testword);
- } // end if
- } // end for
- println("");
- } // end modulo if
- } // end draw
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement