Updated how results are retrieved

This commit is contained in:
2020-07-20 00:53:08 -04:00
parent 22871b71e9
commit 2616dabe6d
67 changed files with 132 additions and 434 deletions

View File

@@ -75,6 +75,9 @@ void Problem4::solve(){
//Stop the timer
timer.stop();
//Save the results
result << "The largest palindrome is " << *(palindromes.end() - 1);
//Throw a flag to show the problem is solved
solved = true;
}
@@ -85,18 +88,6 @@ void Problem4::reset(){
palindromes.clear();
}
//Return a string with the solution to the problem
std::string Problem4::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
throw Unsolved();
}
//Print the results
std::stringstream results;
results << "The largest palindrome is " << *(palindromes.end() - 1);
return results.str();
}
//Returns the list of all palindromes
std::vector<uint64_t> Problem4::getPalindromes() const{
//If the problem hasn't been solved throw an exception