combine trees fix err not appearing

This commit is contained in:
vrd
2023-07-22 12:48:51 +03:00
parent 291168d507
commit 6a71d7e13c
6 changed files with 56 additions and 69 deletions
+30 -29
View File
@@ -9,44 +9,42 @@
using std::cout;
using std::string;
static WINDOW* info_tab;
EventTime::EventTime(I16 Year, U8 Month, U16 Day, I8 Hour, I8 Minute)
: year(Year)
, month(Month)
, day(Day)
, hour(Hour)
, minute(Minute)
: year(Year)
, month(Month)
, day(Day)
, hour(Hour)
, minute(Minute)
{
assert(month <= 12 && day <= 31 && hour <= 23 && minute <= 59 && "Invalid EventTime data");
assert(month <= 12 && day <= 31 && hour <= 23 && minute <= 59 && "Invalid EventTime data");
}
void EventTime::print() const
void EventTime::print(WINDOW* info_tab) const
{
if (day != UNKNOWN_DATE)
wprintw(info_tab, "%d", day);
else
waddstr(info_tab, "??");
waddch(info_tab, '.');
if (day != UNKNOWN_DATE)
wprintw(info_tab, "%d", day);
else
waddstr(info_tab, "??");
waddch(info_tab, '.');
if (month != UNKNOWN_DATE)
wprintw(info_tab, "%d", month);
else
waddstr(info_tab, "??");
waddch(info_tab, '.');
if (month != UNKNOWN_DATE)
wprintw(info_tab, "%d", month);
else
waddstr(info_tab, "??");
waddch(info_tab, '.');
if (year != UNKNOWN_DATE)
wprintw(info_tab, "%d", year);
else
waddstr(info_tab, "????");
waddch(info_tab, '\n');
if (year != UNKNOWN_DATE)
wprintw(info_tab, "%d", year);
else
waddstr(info_tab, "????");
waddch(info_tab, '\n');
}
Person::Person(const char* aName, EventTime aBirth, Sex aSex, EventTime aDeath)
: name(aName)
, birth(aBirth)
, sex(aSex)
, sex(aSex)
, death(aDeath)
{
}
@@ -54,21 +52,24 @@ Person::Person(const char* aName, EventTime aBirth, Sex aSex, EventTime aDeath)
bool Person::operator==(const Person &other)const
{
return name == other.name; //&& sex == other.sex; //TODO && day == other.day || !day || !other.day) && (month == other.month || !month || !other.month) && (year == other.year || !year || !other.year);
return sex == other.sex && name == other.name &&
(birth.day == other.birth.day || birth.day == EventTime::UNKNOWN_DATE || other.birth.day == EventTime::UNKNOWN_DATE) &&
(birth.month == other.birth.month || birth.month == EventTime::UNKNOWN_DATE || other.birth.month == EventTime::UNKNOWN_DATE) &&
(birth.year == other.birth.year || birth.year == EventTime::UNKNOWN_DATE || other.birth.year == EventTime::UNKNOWN_DATE);
}
void Person::displayInfo()const
{
info_tab = newwin(LINES, COLS, 0, 0);
WINDOW* info_tab = newwin(LINES, COLS, 0, 0);
waddstr(info_tab, name.data());
waddch(info_tab,'\n');
waddstr(info_tab, "Birth: ");
birth.print();
birth.print(info_tab);
waddstr(info_tab, "Death: ");
death.print();
death.print(info_tab);
mvwaddstr(info_tab, LINES-1, 0, "Press any key to return.");