2015-11-24 WordSearch update

posted Nov 24, 2015, 7:47 AM by Samuel Konstantinovich   [ updated Nov 24, 2015, 9:37 AM ]
WordSearch updates

1. Make a plain text file "words.txt" and fill it with whatever words you like. 
   -Put in 3,4,5,6, and 7 letter words to help you test.

Update to your WordSearch:
private ArrayList<String> wordsToAdd;
private ArrayList<String> wordsAdded;

2. Open the file in a method called loadWords(String fileName)
- Use a scanner on a file object to be able to read in the words, into wordsToAdd

2b. Make a method void printWordList() so you can test your code.

Now that you got the file input working:
3. In a program Driver.java 
-Make a Word Grid.
-Load the words, print out the ArrayList to see if it worked.


4. Try to add all of those words as randomly as possible using a function 
void fillWithWords()
-This function will use the ArrayList of words, and try to add them to the WordSearch randomly.
-When you successfully add a word, remove it from wordsToAdd, and place it into wordsAdded.
-You can add them all horizontally since you don't have the other methods yet.
-Add as many as you can to the WordSearch, but make sure it doesn't try too many times for each word, allow it to just skip to the next word if it can't find a spot. 

5. In a program Driver.java 
-Make a 7x7 WordSearch.
-Load the words
-Fill the WordSearch using your new function. (do not add random letters)
-Print the wordSearch.

Tomorrow:
You will make AddVertical and AddDiagonal.

Comments