diff options
Autocommit at 28.05.2022 @ 18:29
5 files changed, 12 insertions, 13 deletions
| -rw-r--r-- | src/Models/CellDouble.h | 1 | ||||
| -rw-r--r-- | src/Models/CellFormula.h | 4 | ||||
| -rw-r--r-- | src/Models/CellInt.cpp | 4 | ||||
| -rw-r--r-- | src/Models/CellInt.h | 2 | ||||
| -rw-r--r-- | src/Models/Table.cpp | 14 |
diff --git a/src/Models/CellDouble.h b/src/Models/CellDouble.h index 6396089..736d77a 100644 --- a/src/Models/CellDouble.h +++ b/src/Models/CellDouble.h @@ -10,7 +10,6 @@ public: CellDouble() = default; CellDouble(double value); - double getNumeralValue() override; String getValueForPrint() override; void parseAndSetValue(const char* str) override; void readFromFile(std::ifstream& file) override; diff --git a/src/Models/CellFormula.h b/src/Models/CellFormula.h index e360278..3074846 100644 --- a/src/Models/CellFormula.h +++ b/src/Models/CellFormula.h @@ -5,7 +5,7 @@ #include "../Generic/List/List.hpp" #include "../Generic/Pair/Pair.hpp" -class CellFormula : public Cell<double> { +class CellFormula : public Cell { enum Op { none, plus, @@ -21,8 +21,6 @@ class CellFormula : public Cell<double> { double calculate(unsigned index = 0); - double getValue() override; - public: CellFormula() = default; diff --git a/src/Models/CellInt.cpp b/src/Models/CellInt.cpp index 67f763e..a8f2db5 100644 --- a/src/Models/CellInt.cpp +++ b/src/Models/CellInt.cpp @@ -1,8 +1,8 @@ #include "CellInt.h" #include <cstring> -int CellInt::getNumeralValue() { - return value; +CellInt::CellInt(int value) { + this->value = value; } String CellInt::getValueForPrint() { diff --git a/src/Models/CellInt.h b/src/Models/CellInt.h index 53ddda7..ed336b9 100644 --- a/src/Models/CellInt.h +++ b/src/Models/CellInt.h @@ -8,8 +8,8 @@ class CellInt : public Cell { public: CellInt() = default; + CellInt(int value); - double getNumeralValue() override; String getValueForPrint() override; void parseAndSetValue(const char* str) override; void readFromFile(std::ifstream& file) override; diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index bcaffb7..5d0c87f 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -19,12 +19,14 @@ bool containsNumber(const char*& str) { } void Table::putCell(unsigned row, unsigned col, const char* rawValue) { - unsigned intParse = atoi(rawValue); - unsigned doubleParse = atof(rawValue); Cell* newCell; - if (doubleParse - intParse > 0.00001 && doublePrase > 0.00001) - newCell = new CellDouble(doubleParse); - else if (intParse ) - newCell = + if (containsNumber(rawValue)) { + unsigned intParse = atoi(rawValue); + unsigned doubleParse = atof(rawValue); + + newCell = (doubleParse - intParse > 0.00001 && doubleParse > 0.00001) + ? new CellDouble(doubleParse) : new CellInt(intParse); + } + } |
