copyright Steve J. Hodges   http://steveh.net/cs19/cs19-hw04.html

CS19 Spring 2018

Assignment 4 (Bingo! Word Gamesearch)

Directory Name

19-4

executable Resulting from make (set in makefile)

p4

Starter Code

required starter code

Program Description

In this program, you will be finding six or seven letter words that can be made from a set of letters. Your program will feature the interaction of two objects. The Bingo object will manage the input and output and will utilize a Dictionary object (via composition.) To find candidate words, the basic technique you will use is to sort the letters in the word so that they are in alphabetical order to facilitate comparison. Your Dictionary object will support the word list. This assignment will also feature the use of the STL Map.

Program Output

Your program will output a list of seven letter words that can be made from the set of input letters. If no seven letter words can be made, then output a list of six letter words that can be made. Any word should only appear once in your list. If no six or seven letter words can be made, then let the user know that. Make sure the style and content of your output match the examples.

Command Line Parameters and Input

Your program will accept up to two optional inputs "-f filename" and "-g guess" where filename is the filename of words to use as the programs word list, and guess is a string of exactly seven letters (only) to be used as the set of letters to find matching words for. If both parameters are present, then the program will have no additional input. If the "-f" option is omitted, use the filename "unixdict.txt" If the "-g" option is omitted, prompt the user to input their letters. When the letters are input via STDIN, allow/discard non-letter portions of the input. In either case, confirm that the guess is exactly seven letters. Halt the program on invalid input with an informative message. I've copied the file unixdict.txt to your home directory on Pengo, and your program should work with any text file with one word per line.

Dictionary Class

The Dictionary will feature a Map<string, vector<string> > to store your words. This class is required to have a function named add(string) that adds a word to your Map in the appropriate position. you will also have a function named find(string) that returns a vector of strings of words that can be made by using all of the letters in the paramter. Return seven letter words if the parameter is seven letters, and six letter words if the parameter is six letters. See the starter code for more details.

Main function

See the starter code for the required code for your main function.

Bingo Class

The constructor should read all the words from the file(name parameter) and store the six and seven length entries in the dictionary. Your Bingo class is required to have a play function. See the starter code for more details.

Sample Runs

[steveh@pengo Bingo]$ ./p4 -f unixdict.txt -g gabdire
looking for anagrams of "gabdire" ...
7 letters: [abridge, brigade]
[steveh@pengo Bingo]$
[steveh@pengo Bingo]$ ./p4 -g aeiinmr -f unixdict.txt
looking for anagrams of "aeiinmr" ...
6 letters: [airmen, marine]
[steveh@pengo Bingo]$
[steveh@pengo Bingo]$ ./p4 -f unixdict.txt
Your letters? a, e, i, i, n, m, z
looking for anagrams of "aeiinmz" ...
No six or seven letter words found.
[steveh@pengo Bingo]$