编写一个日期类Date,它有三个数据:year,month,day
题目
编写一个日期类Date,它有三个数据:year,month,day
编写一个日期类Date,它有三个数据:year,month,day.涉及的操作有给数据赋值、输出数据的值.定义一个Student类,包含数据成员 birthday(出生年月)这个数据,birthday的数据类型为Date,学号,姓名,语文、数学、英语的成绩.实现对类的动态调用,输出学号、姓名、出生年月,成绩总和.要求用到构造函数.
答案
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,.);
}
}
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
热门考点
- 已知集合M=(-3,5],N=[-5,5),若全集U=[-5,a],且(CuM)∩(CuN)=(5,a],求a%
- (1)实验小学的同学们参观消防知识展览,三、四年级一共来了945名同学,5倍.三、四年级各来了多少人?
- 一个4.5米高,直径2米的柴油,能装多少吨柴油.
- shanghai is big and beautiful
- May the joy and happiness around you today and always. (Love is blind. )(Love at first sight.)
- 下面关于计算机病毒说法不正确的是
- how long have you been in China?——Since last Wednesday 啥意思
- 英语翻译
- 求实验室制乙醛,工业制乙醛的方程式.
- 为什么3次写教室外面的玫瑰花开的好红啊!