Website Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commit2929a4a6e811ddc2c2073158f50d2e20170c6c6a (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 20:28:24 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 20:28:24 +0300
Files2fc70dc8ce6d25859696484b2810b381af13cba4 /src
FMI-OOP-P2_Tables-2929a4a6e811ddc2c2073158f50d2e20170c6c6a.tar
FMI-OOP-P2_Tables-2929a4a6e811ddc2c2073158f50d2e20170c6c6a.tar.gz
FMI-OOP-P2_Tables-2929a4a6e811ddc2c2073158f50d2e20170c6c6a.zip
Parentd5f4221f7820a774fd209c7a75a8a526aeec7ee2 (diff)
Autocommit at 30.05.2022 @ 20:28
4 files changed, 10 insertions, 2 deletions
-rw-r--r--src/Models/Table.cpp5
-rw-r--r--src/Models/Table.h2
-rw-r--r--src/UserInterface/UserInterface.cpp1
-rw-r--r--src/main.cpp4
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index 4aab10e..a4103be 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -113,6 +113,10 @@ Table::Table(unsigned rows, unsigned cols) {
cells[i] = List<Cell*>(cols);
}
+unsigned Table::get_rows() const {
+ return cells.get_length();
+}
+
unsigned Table::get_cols() const {
return cells[0].get_length();
}
@@ -128,6 +132,7 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) {
? (Cell*)new CellDouble(doubleParse) : (Cell*)new CellInt(intPart);
}
else if (*rawValue == '"') {
+ rawValue++;
newCell = (*rawValue == '=')
? (Cell*)new CellFormula(rawValue, &cells) : (Cell*)new CellString(rawValue);
}
diff --git a/src/Models/Table.h b/src/Models/Table.h
index 41d9d7f..eb62e2c 100644
--- a/src/Models/Table.h
+++ b/src/Models/Table.h
@@ -12,6 +12,8 @@ class Table {
public:
Table(const char* filePath);
Table(unsigned rows, unsigned cols);
+
+ unsigned get_rows() const;
unsigned get_cols() const;
void putCell(unsigned row, unsigned col, const char* rawValue);
diff --git a/src/UserInterface/UserInterface.cpp b/src/UserInterface/UserInterface.cpp
index 190bb54..2edd22e 100644
--- a/src/UserInterface/UserInterface.cpp
+++ b/src/UserInterface/UserInterface.cpp
@@ -115,6 +115,7 @@ void UserInterface::com_edit(const char* params) {
try {
table->putCell(row, col, params);
saved = false;
+ printLine("Successfully edited cell!");
}
catch (std::logic_error err) {
printLine(err.what());
diff --git a/src/main.cpp b/src/main.cpp
index aa26856..0f47890 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,8 +4,8 @@ int main() {
Table table(5, 5);
table.putCell(0, 0, "8.6");
table.putCell(0, 1, "0");
- table.putCell(0, 2, "String");
- table.putCell(0, 3, "= 3 * R0C1 + R0C0 ^ R0C1 * 27 / R0C1 - 2 * 2.5 * 2 * 2 + R0C2 ^ R0C2");
+ table.putCell(0, 2, "\"String");
+ table.putCell(0, 3, "\"= 3 * R0C1 + R0C0 ^ R0C1 * 27 / R0C1 - 2 * 2.5 * 2 * 2 + R0C2 ^ R0C2 + R9999C999999");
// table.putCell(0, 3, "= 1 + 2 * 3 + 4 + 5");
UserInterface ui(&table);
ui.run();