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:
@@ -61,6 +61,9 @@ void Problem2::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The sum of the even Fibonacci numbers less than 4,000,000 is " << fullSum;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -71,17 +74,6 @@ void Problem2::reset(){
|
||||
fullSum = 0;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem2::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The sum of the even Fibonacci numbers less than 4,000,000 is " << fullSum;
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the requested sum
|
||||
uint64_t Problem2::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user