- 1、本文档共13页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
nextday 软件测试
吉林大学应用技术学院
实验(训)报告单(电子版)
实验编号 2 实验班级 实验名称 测试nextdate 任务书编号 1 实验组别 实验组成员 报告人 指导教师 实 验 报 告
代码: #ifndef _Date_H
#define _Date_H
#includeiostream.h
class Date
{
public:
Date(){}
Date(int,int,int);
Date(Date );
~Date(){}
void setDate(int,int,int);
bool IsLeapYear() const;
int TimeElapsed() const;
void NextDate();
void print();
private:
int year;
int month;
int day;
};
#endif
#includeiostream.h
#include stdlib.h
Date::Date(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
Date::Date(Date a)
{
year=a.year;
month=a.month;
day=a.day;
}
void Date::setDate(int y,int m,int d)
{
year=y;
month=m;
day=d;
int tof;
if((year1919year2051)(month0month13))
{
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
{
if(day0day32)
{
tof=1;
break;
}
else
{
tof=0;
break;
}
}
case 4:
case 6:
case 9:
case 11:
{
if(day0day31)
{
tof=1;
break;
}
else
{
tof=0;
break;
}
}
case 2:
{
if((IsLeapYear()day0day30)||(!IsLeapYear()day0day29))
{
tof=1;
break;
}
else
{
tof=0;
break;
}
}
default:
{
tof=0;
break;
}
}
}
else
{
tof=0;
}
if(tof==0)
{
cout请输入正确的年月日endl;
exit(1);
}
}
bool Date::IsLeapYear() const
{
return (year%400==0)||(year%100!=0)(year%4==0);
}
int Date::TimeElapsed() const
{
int sum=0;
int b;
if(IsLeapYear())
b=29;
else
b=28;
return 0;
}
void Date::NextDate()
{
if((year1900year2050)(month0month13))
文档评论(0)