Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commit7a566fe28b9beef1e31c73b82678caf427fbc70a (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 22:03:57 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 22:03:57 +0300
Files1661520fc76884a21125536b11e5c59d1db4f0ce /src/Models/Table.cpp
FMI-OOP-P2_Tables-7a566fe28b9beef1e31c73b82678caf427fbc70a.tar
FMI-OOP-P2_Tables-7a566fe28b9beef1e31c73b82678caf427fbc70a.tar.gz
FMI-OOP-P2_Tables-7a566fe28b9beef1e31c73b82678caf427fbc70a.zip
Parentff487bc9ef5c5704f797900e9049227641958606 (diff)
Autocommit at 30.05.2022 @ 22:03
1 files changed, 4 insertions, 7 deletions
-rw-r--r--src/Models/Table.cpp11
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index 7db0270..bbf22a6 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -78,12 +78,10 @@ void Table::readFromFile(std::ifstream& inFile) {
if (inFile.peek() != ' ' && inFile.peek() != ',' && inFile.peek() != '\n')
throw std::logic_error(fileLocationExceptionMsg("Error: Expected space, comma or newline but got something else at row ", cells.get_count(), inFile.tellg() % cols + 1));
- Cell* toAdd;
if (exponent == 1)
- toAdd = (Cell*)new CellInt(whole);
+ cells[cells.get_count() - 1][colInd++] = (Cell*)new CellInt(whole);
else
- toAdd = (Cell*)new CellDouble((double)whole / exponent);
- cells[cells.get_count() - 1][colInd++] = toAdd;
+ cells[cells.get_count() - 1][colInd++] = (Cell*)new CellDouble((double)whole / exponent);
}
// Parsing string or formula
else if (inFile.peek() == '"') {
@@ -162,9 +160,8 @@ List<String> Table::getAllCells() const {
List<String> toRet;
for (unsigned i = 0; i < cells.get_length(); i++) {
for (unsigned j = 0; j < cells[i].get_length(); j++) {
- std::cout << "here" << std::endl;
- if (cells[i][j] == nullptr)
- toRet.add("");
+ std::cout << i << ' ' << j << std::endl;
+ if (cells[i][j] == nullptr) toRet.add("");
else toRet.add(cells[i][j]->getValueForPrint());
}
}