mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated how results are retrieved
This commit is contained in:
@@ -62,6 +62,9 @@ void Problem1::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The sum of all the numbers < " << MAX_NUMBER + 1 << " that are divisible by 3 or 5 is " << fullSum;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -72,20 +75,8 @@ void Problem1::reset(){
|
||||
fullSum = 0;
|
||||
}
|
||||
|
||||
|
||||
//Gets
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem1::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
//Create a string with the results and return it
|
||||
std::stringstream results;
|
||||
results << "The sum of all the numbers < " << MAX_NUMBER + 1 << " that are divisible by 3 or 5 is " << fullSum;
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the requested sum
|
||||
uint64_t Problem1::getSum() const{
|
||||
//If the prblem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
|
||||
Reference in New Issue
Block a user