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

@@ -72,6 +72,9 @@ void Problem5::solve(){
//Stop the timer
timer.stop();
//Save the results
result << "The smallest positive number evenly divisible by all numbers 1-20 is " << smallestNum;
//Throw a flag to show the problem is solved
solved = true;
}
@@ -82,17 +85,6 @@ void Problem5::reset(){
smallestNum = 0;
}
//Return a string with the solution to the problem
std::string Problem5::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
throw Unsolved();
}
std::stringstream results;
results << "The smallest positive number evenly divisible by all numbers 1-20 is " << smallestNum;
return results.str();
}
//Returns the requested number
int Problem5::getNumber() const{
//If the problem hasn't been solved throw an exception