Website Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commit1ba06048bfd4f007fec254bc964f2983c1793169 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-29 08:08:50 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-29 08:08:50 +0300
Files994af2b5bf29e772e62f3c5fd69119bb6f2bbd87 /src
FMI-OOP-P2_Tables-1ba06048bfd4f007fec254bc964f2983c1793169.tar
FMI-OOP-P2_Tables-1ba06048bfd4f007fec254bc964f2983c1793169.tar.gz
FMI-OOP-P2_Tables-1ba06048bfd4f007fec254bc964f2983c1793169.zip
Parentb2abeda801b8f8f092bc138b7aba8ec208194e7e (diff)
Autocommit at 29.05.2022 @ 08:08
3 files changed, 26 insertions, 16 deletions
-rw-r--r--src/Generic/ConsoleInterface/Toolbox.cpp21
-rw-r--r--src/Models/CellFormula.cpp14
-rw-r--r--src/main.cpp7
diff --git a/src/Generic/ConsoleInterface/Toolbox.cpp b/src/Generic/ConsoleInterface/Toolbox.cpp
index 5a434da..8a4470d 100644
--- a/src/Generic/ConsoleInterface/Toolbox.cpp
+++ b/src/Generic/ConsoleInterface/Toolbox.cpp
@@ -57,7 +57,11 @@ void __printTableLine(unsigned columns) {
}
void __printPadded(const String& str, unsigned width) {
-
+ while (str.get_length() - width > 0) {
+ width--;
+ print(" ");
+ }
+ print(str.get_cstr());
}
/*! \param startNumber The number by which column and row enumeration begins
@@ -81,17 +85,12 @@ void table(const List<String>& items, unsigned columns) {
for (unsigned i = 0; i < items.get_count(); i++) {
__printPadded(items[i], colWidths[i % columns]);
+ if (i > 0 && i % columns == 0)
+ printLine("");
+ else if (i % columns > 0 && i % columns < columns - 1)
+ print("|");
}
- __printTableHeaderNumber(startNumber);
- for (unsigned i = 0, colInd = 0, rowInd = 0; items[i] != '\0'; i++, (++colInd) %= columns) {
- if (colInd == 0 && i != 0) {
- std::cout << ":" << std::endl;
- __printTableLine(columns);
- __printTableHeaderNumber((++rowInd) + startNumber);
- }
- std::cout << ((colInd == 0) ? "║ " : "| ") << items[rowInd * columns + colInd] << " ";
- }
- std::cout << ":" << std::endl;
+ delete[] colWidths;
}
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 1a340e5..cf1c2cd 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -2,11 +2,6 @@
#include "CellDouble.h"
#include <cstring>
-CellFormula::CellFormula(const char* str, const List<List<Cell*>>* tableCells) : localCells(), formula(), rawFormula() {
- this->tableCells = tableCells;
- parseAndSetValue(str);
-}
-
double pow(double x, unsigned y) {
double res = x;
for (unsigned i = 1; i < y; i++)
@@ -38,6 +33,15 @@ double CellFormula::calculate(unsigned index) {
}
}
+CellFormula::CellFormula(const char* str, const List<List<Cell*>>* tableCells) : localCells(), formula(), rawFormula() {
+ this->tableCells = tableCells;
+ parseAndSetValue(str);
+}
+
+double CellFormula::getNumeralValue() {
+ return 0;
+}
+
String CellFormula::getValueForPrint() {
return String() += calculate();
}
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..3ce8563
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,7 @@
+#include "UserInterface/UserInterface.h"
+
+int main() {
+ Table table(5, 5);
+ UserInterface ui(table);
+ ui.run();
+}