Updated how results are retrieved

This commit is contained in:
2020-07-20 00:53:08 -04:00
parent 22871b71e9
commit 2616dabe6d
67 changed files with 132 additions and 434 deletions

View File

@@ -174,6 +174,10 @@ void Problem11::solve(){
//Stop the timer
timer.stop();
//Save the results
result << "The greatest product of 4 number in a line is " << mee::getProduct(greatestProduct)
<< "\nThe numbers are " << greatestProduct.at(0) << ' ' << greatestProduct.at(1) << ' ' << greatestProduct.at(2) << ' ' << greatestProduct.at(3);
//Throw a flag to show the problem is solved
solved = true;
}
@@ -184,18 +188,6 @@ void Problem11::reset(){
greatestProduct.clear();
}
//Return a string with the solution to the problem
std::string Problem11::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
throw Unsolved();
}
std::stringstream results;
results << "The greatest product of 4 number in a line is " << mee::getProduct(greatestProduct)
<< "\nThe numbers are " << greatestProduct.at(0) << ' ' << greatestProduct.at(1) << ' ' << greatestProduct.at(2) << ' ' << greatestProduct.at(3);
return results.str();
}
//Returns the numbers that were being searched
std::vector<int> Problem11::getNumbers() const{
//If the problem hasn't been solved throw an exception