|
Bill Teter email: william.teter@plattsburgh.edu |
|
|
Lab 7 In this lab you will develop a helper tool for Scrabble players. The Scrabble player is challenged to come up with words that use some subset of the letters he/+she currently holds and which can be added somewhere to the existing words on the Scrabble board. The user will start your program, and then be prompted (in an infinite loop) to enter a sequence of alphabetical characters. (The same character may occur more than once.) Your program will print all the words found in the Scrabble dictionary that can be formed with these characters. You will need a Sequences class. The class will contain a static method called sequences() that has a single String type parameter and that will construct and return the set of all sequences that can be made from any of the characters from a given string in any possible order, including the empty string. public static Set<String> sequences(String s) For example: from the characters abc, the following
sequences can be formed. Here is a recursive algorithm for the sequences method.... To make this work you will need to understand the substring method from the String class. Also, thoroughly test this method before going to the next step. Your main program will be called Scrabble. WORD.LST is a file of all allowed words for Scrabble. Your program will read and then add all the words from the file WORD.LST which is in the public directory for lab7, and place each word in a HashSet which you might call dictionary. The main method will then prompt and read in a client's string of characters, generate all the sequences generated from those characters, and print those that occur in the dictionary The program should run until user enters ctrl-d. The public directory does contain the .class files for a solution to this lab. You can run them from that directory: java Scrabble For this lab you will create two classes: Scrabble.java and Sequences.java. |