//ProjectEuler/C++/Headers/Problem.hpp //Matthew Ellison // Created: 07-04-19 //Modified: 07-10-19 //This is an abstract base class to allow polymorphism for the individual problems #ifndef PROBLEM_HPP #define PROBLEM_HPP #include #include "Stopwatch.hpp" class Problem{ protected: const std::string description; //Holds the description of the problem 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 public: //Constructors Problem() : solved(false){ } Problem(std::string description) : description(description), solved(false){ } virtual ~Problem(){ } virtual std::string getDescription() const{ return description; } virtual std::string getTime(){ return timer.getStr(); } virtual mee::Stopwatch getTimer(){ return timer; } virtual void solve() = 0; virtual std::string getString() const = 0; virtual void reset(){ timer.reset(); solved = false; } }; #endif //PROBLEM_HPP