mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Updated how results are retrieved
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user