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

@@ -85,6 +85,9 @@ void Problem30::solve(){
//Throw a flag to show the problem is solved
solved = true;
//Save the results
result << "The sum of all the numbers that can be written as the sum of the fifth powers of their digits is " << getSumOfList();
}
//Reset the problem so it can be run again
@@ -93,19 +96,6 @@ void Problem30::reset(){
sumOfFifthNumbers.clear();
}
//Return a string with the solution to the problem
std::string Problem30::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
throw Unsolved();
}
std::stringstream results;
results << "The sum of all the numbers that can be written as the sum of the fifth powers of their digits is " << getSumOfList();
return results.str();
}
//This returns the top number to be checked
uint64_t Problem30::getTopNum() const{
//If the problem hasn't been solved throw an exception