diff options
| Commit | 68f6b62e49916a59442f4ae69fc0554bf1d84f3a (patch) | |
|---|---|---|
| Author | 2022-05-28 18:29:27 +0300 | |
| Committer | 2022-05-28 18:29:27 +0300 | |
| Files | 81793fa66cb694f9312fd97f5496f600d3c8cfef /src | |
| FMI-OOP-P2_Tables-68f6b62e49916a59442f4ae69fc0554bf1d84f3a.tar FMI-OOP-P2_Tables-68f6b62e49916a59442f4ae69fc0554bf1d84f3a.tar.gz FMI-OOP-P2_Tables-68f6b62e49916a59442f4ae69fc0554bf1d84f3a.zip | ||
| Parent | 9e7af3dd34b747c44aeb2b29fcef7531dc83b17b (diff) | |
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); + } + } |
