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:
@@ -66,6 +66,15 @@ void Problem9::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
if(found){
|
||||
result << "The Pythagorean triplet is " << a << ' ' << b << ' ' << (int)c
|
||||
<< "\nThe numbers' product is " << a * b * (int)c;
|
||||
}
|
||||
else{
|
||||
result << "The number was not found!";
|
||||
}
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -79,24 +88,6 @@ void Problem9::reset(){
|
||||
found = false;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem9::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
std::stringstream results;
|
||||
if(found){
|
||||
results << "The Pythagorean triplet is " << a << ' ' << b << ' ' << (int)c
|
||||
<< "\nThe numbers' product is " << a * b * (int)c;
|
||||
}
|
||||
else{
|
||||
results << "The number was not found!";
|
||||
}
|
||||
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the length of the first side
|
||||
int Problem9::getSideA() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user