mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Moved files around to better match C++ norms
Changed results to match other languages
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//ProjectEuler/ProjectEulerCPP/Headers/Problem.hpp
|
||||
//ProjectEuler/ProjectEulerCPP/headers/Problem.hpp
|
||||
//Matthew Ellison
|
||||
// Created: 07-04-19
|
||||
//Modified: 07-09-20
|
||||
//Modified: 08-28-20
|
||||
//This is an abstract base class to allow polymorphism for the individual problems
|
||||
/*
|
||||
Copyright (C) 2020 Matthew Ellison
|
||||
@@ -35,7 +35,6 @@ protected:
|
||||
mee::Stopwatch timer; //Used to determine your algorithm's run time
|
||||
bool solved; //Holds true after the problem has been solved
|
||||
class Unsolved{}; //An exception class thrown if you try to access something before it has been solved
|
||||
std::stringstream result; //Get the result of the problem
|
||||
public:
|
||||
//Constructors
|
||||
Problem() : solved(false){
|
||||
@@ -67,20 +66,14 @@ public:
|
||||
}
|
||||
//Reset the problem so it can be run again
|
||||
virtual void reset(){
|
||||
result.str(std::string());
|
||||
timer.reset();
|
||||
solved = false;
|
||||
}
|
||||
//Return a string with the solution to the problem
|
||||
virtual std::string getResults(){
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
//Pure virtual functions
|
||||
virtual void solve() = 0; //Solve the problem
|
||||
//Solve the problem
|
||||
virtual void solve() = 0;
|
||||
//Return a string with the solution to the problem
|
||||
virtual std::string getResult() = 0;
|
||||
};
|
||||
|
||||
#endif //PROBLEM_HPP
|
||||
|
||||
Reference in New Issue
Block a user