diff options
| Commit | c038f8f4bdbd3d1fdfa328d2eac0efdcaeb9cb09 (patch) | |
|---|---|---|
| Author | 2022-05-28 19:09:42 +0300 | |
| Committer | 2022-05-28 19:09:42 +0300 | |
| Files | 7d17c621731668dd3ccfe3b79f2848daea4b0c13 /src | |
| FMI-OOP-P2_Tables-c038f8f4bdbd3d1fdfa328d2eac0efdcaeb9cb09.tar FMI-OOP-P2_Tables-c038f8f4bdbd3d1fdfa328d2eac0efdcaeb9cb09.tar.gz FMI-OOP-P2_Tables-c038f8f4bdbd3d1fdfa328d2eac0efdcaeb9cb09.zip | ||
| Parent | 64d959af1090f5d7101c3c78153106871db7e902 (diff) | |
Autocommit at 28.05.2022 @ 19:09
2 files changed, 17 insertions, 11 deletions
| -rw-r--r-- | src/Models/CellFormula.cpp | 24 | ||||
| -rw-r--r-- | src/Models/Table.cpp | 4 |
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp index 09883c2..3029a19 100644 --- a/src/Models/CellFormula.cpp +++ b/src/Models/CellFormula.cpp @@ -11,18 +11,22 @@ double CellFormula::calculate(unsigned index) { if (formula[index].right & branch) { switch (formula[index++].right & !branch) { - case plus: lval += formula[index].left->getNumeralValue(); break; + case plus : lval += formula[index].left->getNumeralValue(); break; + case minus : lval -= formula[index].left->getNumeralValue(); break; + case mult : lval *= formula[index].left->getNumeralValue(); break; + case div : lval /= formula[index].left->getNumeralValue(); break; + // case pow : lval += formula[index].left->getNumeralValue(); break; } } switch(formula[index].right) { - case plus: return lval + calculate(index++); - case minus: return lval - calculate(index++); - case mult: return lval * calculate(index++); - case div: return lval / calculate(index++); - case pow: - case none: - default: return lval; + case plus : return lval + calculate(index++); + case minus : return lval - calculate(index++); + case mult : return lval * calculate(index++); + case div : return lval / calculate(index++); + case pow : + case none : + default : return lval; } } @@ -31,7 +35,9 @@ String CellFormula::getValueForPrint() { } void CellFormula::parseAndSetValue(const char* str) { - + str++; + while (*str == ' ') str++; + double number = atof(str); } void CellFormula::readFromFile(std::ifstream& file) { diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 5840a6e..4bdf13e 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -22,8 +22,8 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { Cell* newCell; if (containsNumber(rawValue)) { - unsigned intParse = atoi(rawValue); - unsigned doubleParse = atof(rawValue); + double intParse = atoi(rawValue); + double doubleParse = atof(rawValue); newCell = (doubleParse - intParse > 0.00001 && doubleParse > 0.00001) ? (Cell*)new CellDouble(doubleParse) : (Cell*)new CellInt(intParse); |
