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

@@ -54,6 +54,9 @@ void Problem3::solve(){
//Stop the timer
timer.stop();
//Save the results
result << "The largest factor of the number " << GOAL_NUMBER << " is " << factors[factors.size() - 1];
//Throw a flag to show the problem is solved
solved = true;
}
@@ -64,17 +67,6 @@ void Problem3::reset(){
factors.clear();
}
//Return a string with the solution to the problem
std::string Problem3::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
throw Unsolved();
}
std::stringstream results;
results << "The largest factor of the number " << GOAL_NUMBER << " is " << factors[factors.size() - 1];
return results.str();
}
//Returns the list of factors of the number
std::vector<uint64_t> Problem3::getFactors() const{
//If the problem hasn't been solved throw an exception