Menu

this had alot of errors // Constructor implementation HighScore::HighScore(const std::string& csvData, char delimiter) { Deserialize(csvData, delimiter); } // Deserialize method implementation voi…

this had alot of errors // Constructor implementation
HighScore::HighScore(const std::string& csvData, char delimiter) {
Deserialize(csvData, delimiter);
}

// Deserialize method implementation
void HighScore::Deserialize(const std::string& csvData, char delimiter) {
std::stringstream ss(csvData);
std::string item;

if (std::getline(ss, item, delimiter)) {
name = item;
}

if (std::getline(ss, item, delimiter)) {
score = std::stoi(item);
}
}

// LoadHighScores method implementation
std::vector HighScore::LoadHighScores(const std::string& filePath) {
std::vector highScores;
std::ifstream file(filePath);

if (file.is_open()) {
std::string line;
while (std::getline(file, line)) {
HighScore highScore(line, ‘,’); // Assuming ‘,’ is the delimiter
highScores.push_back(highScore);
}
file.close();
}
else {
throw std::runtime_error(“Error opening file: ” + filePath);
}

return highScores;
}

OR