TEST
1
#include "date.h" #include "utils.h" #include <iostream> using std::cout; using std::endl; Date::Date():year(1970),month(1),day(1){ } Date::Date(int y, int m, int d):year(y),month(m),day(d){ } void Date::display(){ cout<<year<<"-"<<month<<"-"<<day<<endl; } int Date::getYear() const{ return year; } int Date::getMonth() const{ return month; } int Date::getDay() const{ return day; } int Date::dayOfYear(){ int i,s=0; for(i=1;i<=month-1;i++){ {switch (i) {case 1:s+=31;break; case 2: {if(isLeap(year))s+=29; else s+=28;break;} case 3:s+=31;break; case 4:s+=30;break; case 5:s+=31;break; case 6:s+=30;break; case 7:s+=31;break; case 8:s+=31;break; case 9:s+=30;break; case 10:s+=31;break; case 11:s+=30;break; default:cout<<"errror"<<endl; } } } s+=day; return s; }