void legalPlays(HashTable<string,int> dictionary) { cout << "\nEnter the letters you wish to play: "; string letters; cin >> letters; //getting the letters from the user letters = lowercase(letters); //make lowercase std::vector<string> anagrams = getAllLegalPlays(letters); int anaSize = anagrams.size(); for (int i = 0; i < anaSize; i++) { anagrams[i] = getAlpha(anagrams[i]); //loop sets all the anagrams of the letters to ordered //alphabetical arrangement } std::vector<string> plays; //eventually the vector of strings that will be printed out std::vector<string> allWords = dictionary.getKeys(); int allWordsLength = allWords.size(); for (int h = 0; h < anaSize; h++) { for (int i = 0; i < allWordsLength; i++) { if (anagrams[h] == getAlpha(allWords[i])) { plays.push_back(allWords[i]); //adding to plays if in the dictionary } } } printPlays(plays); //print function for all possible plays menu(dictionary); //back to menu }
void anagrams(HashTable<string,int> dictionary) { cout << "\nEnter the letters you wish to play: "; string letters; cin >> letters; //getting the letters from the user letters = lowercase(letters); //make lowercase letters = getAlpha(letters); std::vector<string> anagrams; //eventually the vector of strings that will be printed out std::vector<string> allWords = dictionary.getKeys(); //vector of all words in the dictionary int allWordsLength = allWords.size(); for (int i = 0; i < allWordsLength; i++) { //loop to check the letters against the dictionary if (letters == getAlpha(allWords[i])) { anagrams.push_back(allWords[i]); //adding to anagrams vector } } printAnagrams(anagrams); //print function to output the anagrams menu(dictionary); //back to menu }