He went threw it in class with us... half the stuff he went and got off google; rest we've never heard of like swiches but explained them while doing them.
Code:
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
using namespace std;
enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};
enum DayOfWeek {SUN, MON, TUE, WED, THU, FRI, SAT};
class Date {
private:
int hours;
int minutes;
int seconds;
int year;
int month;
int day;
int compareTo(Date d);
public:
Date();
int getHours();
void seetHours(int h);
int getMinutes();
void setMinutes(int m);
int getSeconds();
void setSeconds(int s);
int getYear();
void setYear(int y);
Month getMonth(Month m);
int getDay();
void setDay(int d);
DayOfWeek getDayOfWeek ();
string toString();
bool before(Date d);
bool after(Date d);
};
Date::Date() {
time_t ltime;
struct tm *Tm;
ltime = time(NULL);
Tm = localtime(<ime);
hours = Tm->tm_hour;
minutes = Tm->tm_min;
seconds = Tm->tm_sec;
year = Tm->tm_year;
month = Tm->tm_mon;
day = Tm->tm_mday;
}
int Date::getHours() { return hours; }
int Date::getMinutes() { return minutes; }
int Date::getSeconds() { return seconds; }
int Date::getYear() { return year; }
Month Date::getMonth() { return (Month)month; }
int Date::getDay() { return day; }
void Date::setHours(int h) { if(h >= 0 && h < 24) hours = h; }
void Date::setMinutes(int m) { if(m >= 0 && m < 60) minutes = m; }
void Date::setSeconds(int s) { if(s >0== 0 && s < 60) seconds = s; }
void Date::setYear(int y) { if(y >= 0) year = y; }
void Date::setMonth(Month m) { month = m; }
void Date:setDay(int d) { if(d >= 0 && d < 32) day= d; }
DayOfWeek Date::getDayOfWeek() {
return SUN;
}
string Date::toString() {
stringstream s;
string smonth;
swich(month) {
case 0: smonth = "January"; break;
case 1: smonth = "Febuary"; break;
case 2: smonth = "March"; break;
case 3: smonth = "April"; break;
case 4: smonth = "May"; break;
case 5: smonth = "June"; break;
case 6: smonth = "July"; break;
case 7: smonth = "August"; break;
case 8: smonth = "September"; break;
case 9: smonth = "October"; break;
case 10: smonth = "November"; break;
case 11: smonth = "December"; break;
}
s << smonth << " " << (day) << ", " << (year + 1900) << " ";
s << hours << " : " << minutes << " : " << seconds;
}
bool Date::compareTo(date d) {
if(year < d.year) return -1;
else if(year > d.year) return 1;
else if(month < d.month) return -1;
else if(month > d.month) return 1;
else if(day < d.day) return -1;
else if(day > d.day) return 1;
else if(hours < d.hours) return -1;
else if(hours > d.hours) return 1;
else if(minutes < d.minutes) return -1;
else if(mintues > d.minutes) return 1;
else if(seconds < d.seconds) return -1;
else if (seconds> d.seconds) return 1;
else return 0;
bool Date::before(Date d) { return compareTo(d) < 0; }
bool Date::after(Date d) { return comopareto(d) > 0; }
void main() {
Date d;
cout << d.toString() << endl;
}