🗑️」 clean: cleanup things and slightly improved ex02/main.cpp

This commit is contained in:
y-syo
2025-09-01 16:00:41 +02:00
parent 7b47994ddd
commit f9c38cfe86
6 changed files with 37 additions and 28 deletions

View File

@@ -13,8 +13,6 @@ Date::Date(void)
Date::Date(std::string str)
{
// check format (4 char & isdigit into dash into 2 char isdigit & < 1 && isdigit & < 2, and same for day except ahah funny cuz 30 and 31 and 28 and 29 agfjasfgfjahkfga)
_value = 0;
for (size_t i = 0; str[i]; ++i)
{
if (!isdigit(str[i]) && !((i == (str.length() - 6) || i == (str.length() - 3)) && str[i] == '-'))
@@ -23,6 +21,8 @@ Date::Date(std::string str)
throw std::invalid_argument("invalid date.");
}
}
_value = 0;
for (std::string::iterator it = str.begin(); it < str.end(); ++it)
{
if (!isdigit(*it))

View File

@@ -1,4 +1,5 @@
date | value
2002.01-2 | 5
1971-01-02 | 5
1971-31-02 | 5
2011-01-03 | 3