收藏 分销(赏)

JAVA实验报告date.doc

上传人:Fis****915 文档编号:553133 上传时间:2023-12-07 格式:DOC 页数:3 大小:37.50KB
下载 相关 举报
JAVA实验报告date.doc_第1页
第1页 / 共3页
JAVA实验报告date.doc_第2页
第2页 / 共3页
JAVA实验报告date.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、实验报告课程名称:java班级: 实验成绩: 指导教师:姓名: 实验项目名称:date学号:上机实践日期:实验项目编号:组号:上机实践时间: 学时一、 设计和编码.主要代码段说明(附代码):class MyDate private int year; private int month; private int day;public MyDate(int day, int month, int year) this.day = day; this.month = month; this.year = year;public int getyear() return this.year;publ

2、ic void setyear(int year) this.year = year0?year:0; public int getmonth() return this.month;public void setmonth(int month) if(this.year0) if(month=1 & month= 12) this.month=month; public int getday() return this.day;public int setday(int x) switch(x) case 1: case 3: case 5: case 7: case 8: case 10:

3、 case 12: return 31; case 2: if(year%400=0)|(year%100!=0&year%4=0) return 29; else return 28; default: return 30; public void print() System.out.println(MyDate: + day + - + month + - + year);public void prints() System.out.println(YourDate:+day+-+month+-+year);public class Datepublic static void mai

4、n(String args)int day=7;int yourday=7;int month=7;int yourmonth=7;int year=1990;int youryear=1990;MyDate my_birth=new MyDate(day,month,year);my_birth.setday(day);my_birth.setmonth(month);my_birth.setyear(year);MyDate your_birth=new MyDate(yourday,yourmonth,youryear);your_birth.setday(yourday);your_birth.setmonth(yourmonth);your_birth.setyear(youryear);my_birth.print();your_birth.prints();二、运行结果及分析运行结果:

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服