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:
@@ -84,6 +84,10 @@ void Problem8::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The greatest product is " << maxProduct
|
||||
<< "\nThe numbers are " << maxNums;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -95,18 +99,6 @@ void Problem8::reset(){
|
||||
maxProduct = 0;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem8::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
results << "The greatest product is " << maxProduct
|
||||
<< "\nThe numbers are " << maxNums;
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the string of numbers that produces the largest product
|
||||
std::string Problem8::getLargestNums() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user