Programming
Assignment 7
Due April 26, before
midnight |
|||||||||||
Program Description |
|||||||||||
For
instant messaging on a cellphone, the digit keys {2,3,4,5,6,7,8,9} are
pressed to spell a word. Each digit corresponds to a subset of
letters as shown in the photo below
As
can be seen, the digits "1" and "0" are not associated with
letters. The other digits are assigned the following possible
letters
Here
are two example digit sequences, and possible words they spell:
"229" can spell the
words "bay" or "caw"
"269"
can spell "amy", "any", "bmw", "bow", "box", "boy", "cow", "cox", or
"coy"
In this assignment, you will implement methods that given a sequence of digits, will find all possible matching words in a dictionary. The dictionary class is provided, and a text file containing words for the dictionary class is provided. |
|||||||||||
What You Do
|
|||||||||||
It is assumed that
you are using NetBeans to develop your code for this assignment. Create a new NetBeans project that is a
"General" "Java Application". Name your
NetBeans project program7. Download the source for the Main.java, Dictionary.java, and PhoneSpeller.java classes, and store these in the program7/src/program7 directory. Also download the file words, and store this in the same directory. Note: Be sure to modify the source of PhoneSpeller.java to specify the correct file location for you copy of the file words. Using NetBeans, you are to implement a recursive static method for the class PhoneSpeller:
This
recursive method
finds
all the possible combinations of letters that are valid for an input
sequence of digits, returned as a vector of strings. If
the string contains a 1 or 0, then there are no combinations of letters
possible, and this method must return a Vector which is empty.
This method must be implemented using recursion.
You can assume that the input String digits contains only digits.
This
method finds all the possible words in the dictionary that could
possibly be spelled using all possible combinations of letters for each
digit.
Use the static method Dictionary.findWord(String s) to determine what words are listed in the dictionary. Recursive
Algorithm
There are many ways
to implement the recursive algorithm for findAllCombos. It is suggested that the
base case is
used when a number string is only 1 digit long, and the recursive case
is used when the length of the number string is greater than 1. |
|||||||||||
What You Submit
|
|||||||||||
Submit
your file called PhoneSpeller.java
in a directory named 07
via gsubmit
. Under no circumstances will late assignments be accepted. |
|||||||||||
Grading Criteria
|
|||||||||||
20%
Submitted code
compiles without errors 20% findAllCombos returns the correct values for the cases given in Main.java 20% findAllCombos returns the correct values for the cases given at testing time 20% findAllWords returns the correct values for the cases given in Main.java 20% findAllWords returns the correct values for the cases given at testing time |
|||||||||||