JAVA中的stu什么意思_JAVA编程作业完成下⾯⽗类和⼦类的
定义:(1)定义Stude。。。
共回答了19个问题采纳率:78.9%
⽹上找的,你试试能⽤吗
publicclassStudentimplementsComparable{
publicStudent(Stringno,Stringname){
=no;
=name;
}
publicStudent(){
}
publicStudent(Stringno,Stringname,doubleenglish,doublemaths,
doublecomputer,doublesum){
=no;
=name;
h=english;
=maths;
er=computer;
=sum;
}
privateStringno;
privateStringname;
privatedoubleenglish;
privatedoublemaths;
privatedoublecomputer;
privateDoublesum=0.0;
publicStringgetNo(){
returnno;
}
publicvoidtNo(Stringno){
=no;
}
publicStringgetName(){
returnname;
}
publicvoidtName(Stringname){
=name;
}
publicdoublegetEnglish(){
returnenglish;
}
publicvoidtEnglish(doubleenglish){
h=english;
sum+=english;
}
publicdoublegetMaths(){
returnmaths;
}
publicvoidtMaths(doublemaths){
=maths;
sum+=maths;
}
publicdoublegetComputer(){
returncomputer;
}
publicvoidtComputer(doublecomputer){
er=computer;
sum+=computer;
}
publicDoublegetSum(){
returnsum;
}
publicvoidtSum(Doublesum){
=sum;
}
publicStringtoString(){
return"学号:"+no+"姓名"+name+"英语"+english+"数学"+maths+"计算机"+computer+"总成绩"+sum;
}
publicintcompareTo(Objecto){
eTo(((Student)o).getSum());
}
publicDoublesum(){
returnenglish+maths+computer;
}
publicDoubletestScore(){
returnsum/3;
}
}
publicclassStudentXWextendsStudent{
publicStudentXW(Stringno,Stringname){
super(no,name);
}
publicStudentXW(){
super();
}
privateStringduty;
publicStringgetDuty(){
returnduty;
}
publicvoidtDuty(Stringduty){
=duty;
}
publicDoubletestScore(){
ore()+3;
}
}
publicclassStudentBZextendsStudent{
publicStudentBZ(Stringno,Stringname){
super(no,name);
}
publicStudentBZ(){
super();
}
privateStringduty;
publicStringgetDuty(){
returnduty;
}
publicvoidtDuty(Stringduty){
=duty;
}
publicDoubletestScore(){
ore()+5;
}
}
publicclassTest{
publicstaticvoidmain(String[]args){
Studentstudent1=newStudent("001","1");
lish(60.0);
hs(60.0);
puter(60.0);
n(student1+"测试成绩是"+ore());
Studentstudent2=newStudentXW("002","2");
lish(70.0);
hs(70.0);
puter(70.0);
n(student2+"测试成绩是"+ore());
Studentstudent3=newStudentBZ("003","3");
lish(80.0);
hs(80.0);
puter(80.0);
n(student3+"测试成绩是"+ore());
}
}
1年前
2
本文发布于:2023-02-01 00:41:01,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/88/170379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |