Question: Hello there, can you help with code using C++ on unordered_map.h file. I had compiler syntax errors. There are three functions implementation errors: 1) GetLetterValue

Hello there, can you help with code using C++ on unordered_map.h file. I had compiler syntax errors. There are three functions implementation errors:

1) GetLetterValue has incorrect implementation

2) LoadFile has an implementation error

3) FindWordScore has implementation issue and standard for loop iterator error

Here are my codes; I'll give you a thumbs up, thank you.

class DSA_Lab6 { friend class DSA_TestSuite_Lab6; // Giving access to test code

// Data members

int mLetterValues[26]; std::unordered_map mScrabbleMap;

public: // In Scrabble, each letter has a value associated with it. // This method will populate the array of letter values. // // In: _letterValues The array of 26 values.

void PopulateLetterValues(const int* _letterValues) { // TODO: Implement this method for (int i = 0; i

int GetLetterValue(char _letter) const { // TODO: Implement this method

int scoreSingleLetter;// =mLetterValues[_letter-97];

char t = toupper(_letter); scoreSingleLetter += mLetterValues[int(t) - 65]; return scoreSingleLetter;

std::cout

// Get the value of a word // This is done by adding up the values of each letter in the word // // In: _word The word to get the value of // // Return: The total value of the word.

int GetWordValue(const std::string& _word) const { // TODO: Implement this method.

int world = 0; for (int i = 0; i

// Create a pair to add into the scrabbleMap // This will have a \"first\" of the word, and a \"second\" of the total score // // In: _word The word for the pair // // Return: A pair that contains the word and the total score.

std::pair CreatePair(const std::string& _word) const { // TODO: Implement this method.

int volt = CreatePair(_word); std::pair isPair; isPair.first = _word; isPair.second = volt; return isPair; }

// Load a file containing all of the possible scrabble words, along with their values // This file will contain one word per line // In: _filename The name of the file to load // // Note: You may want to use one or more existing methods to help.

void LoadWords(const char* _filename) { // TODO: Implement this method .

std::fstream fileData; //open file.

fileData.open(\"_filename\"); //check file

if (!fileData) { std::cout

else { //create bank object.

std::string line; //read file data.

while (getline(fileData, line)) { if (line.length()) { std::stringstream split(line); std::string huffman; std::vector _data; while (split >> huffman) { _data.push_back(huffman); } mScrabbleMap[_data[0]] = GetWordValue(_data[0]); } } } }

// Searches for a word in the map, and retrieves the score for that word // // In: _word The word to search for // // Return: The word score for _word (or -1 if not found).

int FindValueInMap(const std::string& _word) { // TODO: Implement this method.

unordered_map ::iterator it; for (it = mScrabbleMap.begin(); it != mScrabbleMap.end(); it++) { //find word.

if (it->first == _word) { return it->second; } } return -1; } };

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!