Website Summary Files Commits Branches @commit @diff @stats
path: root / src / ConsoleInterface / Toolbox.cpp
diff options
context:
space:
mode:
Commit1493073a5fe76815bcfcef5aeaed578a821a306c (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-06 09:56:20 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-06 09:56:20 +0300
Files3af631c6191c0c7348e16855c1311ab15afd74b9 /src/ConsoleInterface/Toolbox.cpp
FMI-OOP-P1_TicketSystem-1493073a5fe76815bcfcef5aeaed578a821a306c.tar
FMI-OOP-P1_TicketSystem-1493073a5fe76815bcfcef5aeaed578a821a306c.tar.gz
FMI-OOP-P1_TicketSystem-1493073a5fe76815bcfcef5aeaed578a821a306c.zip
Parent1a0ff4a9dab713514d116ec455c0def715f1302b (diff)
Autocommit at 06.05.2022 @ 09:56
1 files changed, 23 insertions, 5 deletions
-rw-r--r--src/ConsoleInterface/Toolbox.cpp28
diff --git a/src/ConsoleInterface/Toolbox.cpp b/src/ConsoleInterface/Toolbox.cpp
index 25f1c64..31e5277 100644
--- a/src/ConsoleInterface/Toolbox.cpp
+++ b/src/ConsoleInterface/Toolbox.cpp
@@ -32,18 +32,36 @@ void errorBox(const char* message) {
std::cout << "<E> " << message << std::endl;
}
+void __printTableHeaderNumber(unsigned number) {
+ std::cout << ((number < 100) ? " " : "") << number << ((number < 10) ? " " : "");
+}
+
void __printTableColumnHeader(unsigned start, unsigned count) {
- for (unsigned i = 0; i < count; i++, start++)
- std::cout << ":" << ((start < 100) ? " " : "") << start << ((start < 10) ? " " : "");
+ for (unsigned i = 0; i < count; i++) {
+ std::cout << ":";
+ __printTableHeaderNumber(start++);
+ }
std::cout << ":" << std::endl;
+}
- for (unsigned i = 0; i < count; i++)
- std::cout << "....";
- std::cout << "." << std::endl;
+void __printTableLine(unsigned columns) {
+ for (unsigned i = 0; i < columns; i++)
+ std::cout << "----";
+ std::cout << "-" << std::endl;
}
void table(unsigned startNumber, unsigned columns, const char* items) {
__printTableColumnHeader(startNumber, columns);
+
+ for (unsigned i = 0, colInd = 0, rowCnt = startNumber; items[i] != '\0'; i++, (++colInd) %= columns) {
+ if (colInd == 0) {
+ __printTableLine(columns);
+ __printTableHeaderNumber(rowCnt++);
+ continue;
+ }
+
+ std::cout << items[rowCnt * columns + colInd] << std::endl;
+ }
}
void _printOrderedListBeginning() {