当前位置: > 编写一个日期类Date,它有三个数据:year,month,day...
题目
编写一个日期类Date,它有三个数据:year,month,day
编写一个日期类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,.);
}
}
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.