mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2026-02-04 03:52:27 -05:00
Inital commit with existing files
This commit is contained in:
42
Headers/Problem.hpp
Normal file
42
Headers/Problem.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
//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 <string>
|
||||
#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 void solve() = 0;
|
||||
virtual std::string getString() const = 0;
|
||||
};
|
||||
|
||||
#endif //PROBLEM_HPP
|
||||
Reference in New Issue
Block a user