2024-01-05 12:04
BullseyeCoverage 9.6.4
calc/ CalcCore.h
1 // Calculator core logic
2
3 class CalcCore {
4 public:
5 enum class Operation {
6 none,
7 add,
8 divide,
9 multiply,
10 negate,
11 pow2,
12 sqrt,
13 subtract,
14 };
15 void addNumber(double n) { m_displayOperand = n; }
16 void addNumberChar(char c);
17 void apply();
18 void apply(Operation operation);
19 void clear();
20 const char* display() const;
21 static void unitTest();
22 private:
23 char m_input[100] = { };
24 mutable char m_output[100] = { };
25 double m_displayOperand = 0.0;
26 double m_enteredOperand = 0.0;
27 const char* m_error = nullptr;
28 Operation m_operation = Operation::none;
29 void compute();
30 };