Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //add appts to linked list----------------------------------------------------------------------------
- void ToDo::addAppt(Appointment* appt)
- {
- cout << "\nAdding appointment...\n";
- if(head == NULL)
- {
- cout << "\nHead is null..\n";
- head = new Cell(appt, head);
- }
- else
- {
- follow = NULL;
- for(scan = head; scan != NULL; scan = scan -> next)
- {
- if((appt->mWhen <= scan->appt->mWhen) == 1)
- {
- scan->next = new Cell(appt, scan->next);
- break;
- }
- else if((appt->mWhen == scan->appt->mWhen) && (follow == NULL))
- {
- head = new Cell(appt, head);
- break;
- }
- else if((appt->mWhen <= scan->appt->mWhen) == 2 && (follow != NULL))
- {
- follow->next = new Cell(appt, follow->next);
- break;
- }
- follow = scan;
- }
- }
- ++numCells;
- }
- //date.hpp--------------------------------------
- #include "tools.hpp"
- #define DAYS 13
- #define MONTHABR 13
- class Date {
- friend class ToDo;
- private: //------------------------------------------------------------------------
- time_t intTime;
- struct tm myTime;
- static const int nDays[DAYS];
- static const cstring monthAbr[MONTHABR];
- public: //-------------------------------------------------------------------------
- Date(cstring dateString = NULL);
- ~Date();
- void print();
- void format(cstring, bool*, bool*, int*);
- static void instructions();
- static bool valiDate(int month, int day, int year, int hour, int min);
- bool operator<=(const Date & d) const;
- bool operator==(const Date & d) const;
- bool sameDay(const Date & d) const;
- bool sameTime(const Date & d) const;
- friend ostream &operator<<(ostream &stream, const Date o); //compiler throws me errors if I declare this as anything but a friend, can't access private data memeber.
- };
- //date.cpp--------------------------------------------------------------------------
- //compare dates-----------------------------------------------------------------------
- bool Date::operator<=(const Date & d) const
- {
- if(myTime.tm_mon == d.myTime.tm_mon)
- {
- if(myTime.tm_mday >= d.myTime.tm_mday)
- return 1;
- }
- else
- return 2;
- }
- //are dates.mon equal?-----------------------------------------------------------------
- bool Date::operator==(const Date & d) const
- {
- if(myTime.tm_mon <= d.myTime.tm_mon)
- return true;
- else
- return false;
- }
- //are dates.mday equal?-----------------------------------------------------------------
- bool Date::sameDay(const Date & d) const
- {
- if(myTime.tm_mday == d.myTime.tm_mday)
- return true;
- else
- return false;
- }
- //is time equal?------------------------------------------------------------------------
- bool Date::sameTime(const Date & d) const
- {
- if((myTime.tm_hour == d.myTime.tm_hour) && (myTime.tm_min == d.myTime.tm_min))
- return true;
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement