题目
编写一个日期类Date,它有三个数据:year,month,day
编写一个日期类Date,它有三个数据:year,month,day.涉及的操作有给数据赋值、输出数据的值.定义一个Student类,包含数据成员 birthday(出生年月)这个数据,birthday的数据类型为Date,学号,姓名,语文、数学、英语的成绩.实现对类的动态调用,输出学号、姓名、出生年月,成绩总和.要求用到构造函数.
编写一个日期类Date,它有三个数据:year,month,day.涉及的操作有给数据赋值、输出数据的值.定义一个Student类,包含数据成员 birthday(出生年月)这个数据,birthday的数据类型为Date,学号,姓名,语文、数学、英语的成绩.实现对类的动态调用,输出学号、姓名、出生年月,成绩总和.要求用到构造函数.
提问时间:2021-03-23
答案
class Date {
int year=0,month=0,day=0;
public void setY(int year){
this.year=year;
}
public void setM(int month){
this.month=month;
}
public void setD(int day){
this.day=day;
}
public int getY(){
return year;
}
public int getM(){
return month;
}
public int getD(){
return day;
}
}
class Student {
Date d=null;
int num=0;
String s=null;
int china=0,math=0,eng=0;
Student(date d,int num,String s,int china,int math,int eng){
this.d=d;this.num=num;this.s=s;this.china=china;this.math=math;this.eng=eng;
}
public void method(){
System.out.print(d,num,.);
}
}
int year=0,month=0,day=0;
public void setY(int year){
this.year=year;
}
public void setM(int month){
this.month=month;
}
public void setD(int day){
this.day=day;
}
public int getY(){
return year;
}
public int getM(){
return month;
}
public int getD(){
return day;
}
}
class Student {
Date d=null;
int num=0;
String s=null;
int china=0,math=0,eng=0;
Student(date d,int num,String s,int china,int math,int eng){
this.d=d;this.num=num;this.s=s;this.china=china;this.math=math;this.eng=eng;
}
public void method(){
System.out.print(d,num,.);
}
}
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
- 1几道数学题.回答对的加高分.
- 2一个球的外切正方体的的全面积等于6平方厘米,则此球的体积为多少
- 3《真情的回报》的阅读答案
- 4若-π/8
- 5龙的英语单词怎么读
- 6花园里有许多树,但是花不多.怎么翻译成英文.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
- 7已知2SO2(g)+O2(g)⇌2SO3(g);△H=-197kJ•mol-1.向同温、同体积的三个密闭容器中分别充入气体:(甲)2mol SO2和1mol O2;(乙)1mol SO2和0.5mol
- 8金色的鱼钩中 我端起搪瓷碗,觉得这个碗有千斤重,怎么也送不到嘴边.
- 9We have four (class)in the morning.
- 10地震波既有纵波也有横波,纵波和横波在地表附近被认为是匀速传播的,传播速度分别是9、1km/s和3、7km/s,在一次地震观测站记录的纵波和横波到达该地的时间差是8s,则地震的震源据这个观测站有多远?
热门考点
- 1已知集合M=(-3,5],N=[-5,5),若全集U=[-5,a],且(CuM)∩(CuN)=(5,a],求a%
- 2(1)实验小学的同学们参观消防知识展览,三、四年级一共来了945名同学,5倍.三、四年级各来了多少人?
- 3一个4.5米高,直径2米的柴油,能装多少吨柴油.
- 4shanghai is big and beautiful
- 5May the joy and happiness around you today and always. (Love is blind. )(Love at first sight.)
- 6下面关于计算机病毒说法不正确的是
- 7how long have you been in China?——Since last Wednesday 啥意思
- 8英语翻译
- 9求实验室制乙醛,工业制乙醛的方程式.
- 10为什么3次写教室外面的玫瑰花开的好红啊!