-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathequations.hpp
43 lines (38 loc) · 893 Bytes
/
equations.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef EQUATIONS_HPP
#define EQUATIONS_HPP
#include <random>
#include <stack>
#include <vector>
class EquationPiece {
private:
public:
enum class Type { Number, Operation };
Type type;
char operation{'\0'};
double number{0};
EquationPiece(char op);
EquationPiece(double num);
};
class Equation {
private:
std::vector<EquationPiece> equationPieces;
std::string doubleToString(double num) const;
public:
static const std::vector<char> OPERATIONS;
void addNumber(double num);
void addOperation(char op);
std::string toString() const;
double evaluate();
};
class RandomEquationBuilder {
private:
const std::vector<double> NUMBERS;
std::mt19937 eng;
void createRandomEngine();
double randomNumber();
char randomOperation();
public:
RandomEquationBuilder(const std::vector<double> NUMS);
Equation build(const int DESIRED_NUMBER_COUNT_IN_EQUATION);
};
#endif //EQUATIONS_HPP