期中

#include "utils.h" 
#include <iostream>
using std::cout;
using std::endl;
Date::Date(){
    int year=1970;
    int month=1;
    int day=1;}
Date::Date(int y, int m, int d){
    year=y;
    month=m;
    day=d;}
int Date::getYear() const{
    return year;}
int Date::getMonth()const{
    return month;}
int Date::getDay()const{
    return day;}
void Date::display(){
    cout<<getYear()<<"-"<<getMonth()<<"-"<<getDay()<<endl;
}
int Date::dayOfYear(){
    int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int days=0;
    if(isLeap){
        mon[1]=29;}
    for(int i=month-2;i>=0;i--){
        day=mon[i];
        days+=day;}
    return days;}

 

posted @ 2019-04-30 15:06  小啵  阅读(68)  评论(1编辑  收藏  举报