软件测试实验3(2)

2020-05-05 14:03

e.printStackTrace(); } }

public static void main(String[] args) {

CTime time = new CTime(\ time.printNextTime(); } }

2、自定义编写函数 package NextDate; //NextDate函数部分代码 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class NextDate {

private int year;

private int month;

private int day;

public NextDate(int year, int month, int day) { this.year = year;

this.month = month; this.day = day; }

public NextDate() { year = 1; month = 1; day = 1; }

public int getyear() { return this.year; }

public int getmonth() { return this.month; }

public int getday() { return this.day; }

public boolean isleap() { boolean fla1 = true;

if ((this.year % 4 == 0 && this.year % 100 != 0) || (this.year % 400 == 0)) { fla1 = true; } else { fla1 = false; } return fla1;

}

public void nextday() { switch (this.month) { case 1: case 3: case 5: case 7: case 8: case 10:

if (this.day == 31) { this.month = this.month + 1; this.day = 1; } else {

this.day = this.day + 1; } break; case 4: case 6: case 9: case 11:

if (this.day == 30) { this.month = this.month + 1; this.day = 1; } else {

this.day = this.day + 1; } break; case 12:

if (this.day == 31) {

this.month = 1; this.day = 1;

this.year = this.year + 1; } else {

this.day = this.day + 1; } break; case 2:

if (this.isleap()) { if (this.day == 29) { this.day = 1; this.month = 3; } else {

this.day = this.day + 1; } }else {

if (this.day == 28) { this.day = 1; this.month = 3; } else {

this.day = this.day + 1; } } break; } }

public boolean nextday(NextDate date) { boolean fla = true;

if ((date.year < 1912) || (date.year > 2050)) { fla = false; } else {

if ((date.month < 1) || (date.month > 12)) { fla = false; } else {

switch (date.month) { case 1: case 3: case 5: case 7: case 8: case 10:

if (date.day == 31) { date.month = date.month + 1; date.day = 1; } else {

if(date.day<31&&date.day>=1){ date.day = date.day + 1; } else{ fla=false; } } break; case 4:


软件测试实验3(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:论实现社会公平分配的主体、机制及对策

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: