diff options
Autocommit at 08.05.2022 @ 10:08
3 files changed, 14 insertions, 5 deletions
| -rw-r--r-- | src/Generic/Date/Date.cpp | 6 | ||||
| -rw-r--r-- | src/Generic/String/String.cpp | 12 | ||||
| -rw-r--r-- | src/Generic/String/String.h | 1 |
diff --git a/src/Generic/Date/Date.cpp b/src/Generic/Date/Date.cpp index b20de51..db2551a 100644 --- a/src/Generic/Date/Date.cpp +++ b/src/Generic/Date/Date.cpp @@ -71,12 +71,8 @@ int digitToChar(unsigned digit) { } String Date::createCStr() { - unsigned d = day, m = month, y = year; String out; - if (d > 10) { - d - } - (out += itoa(day));// << "." << dt.get_month() << "." << dt.get_year(); + return ((((out += day) += ".") += month) += ".") += year; } void Date::read(std::istream& istr) { diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index bacd72c..251ba0a 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -48,6 +48,18 @@ String& String::operator+=(const char* str) { return *this; } +String& String::operator+=(unsigned number) { + unsigned tempLen = number / 10 + 1; + char* tmp = new char[tempLen + 1]; + tmp[tempLen] = '\0'; + for (unsigned i = tempLen - 1; i >= 0; i--, number /= 10) + tmp[i] = number % 10 + '0'; + + *this += tmp; + delete[] tmp; + return *this; +} + String::String() : String("") {} String::String(const String& other) { diff --git a/src/Generic/String/String.h b/src/Generic/String/String.h index 6217e0a..6a8b014 100644 --- a/src/Generic/String/String.h +++ b/src/Generic/String/String.h @@ -18,6 +18,7 @@ public: unsigned get_length() const; String& operator+=(const char* str); + String& operator+=(unsigned number); String(); String(const String& other); |
