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:
@@ -82,6 +82,9 @@ void Problem14::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The number " << maxNum << " produced a chain of " << maxLength << " steps";
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -93,18 +96,6 @@ void Problem14::reset(){
|
||||
maxNum = 0;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem14::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << "The number " << maxNum << " produced a chain of " << maxLength << " steps";
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the length of the requested chain
|
||||
uint64_t Problem14::getLength() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user