编写一个接口和两个类,要求如下:
设计一个学生功能的接口,实现平均成绩的计算和基本信息的输出。设计一个学生类实现了学生接口,学生类的基本信息有:学号、姓名、年龄、各科成绩。设计一个大学生类继承了学生类:大学生除了包含普通学生的信息外,还包包含:德育成绩、体育成绩、美育成绩;以及一个能够算综合排名成绩的成员方法
最后编写一个main方法测试上面的两个类。
publicinterfaceIStudent{undefinedpublicdoubleavgScore();publicvoidoutputInfo();}
publicclassStudentimplementsIStudent{undefinedprivateStringsno;privateStringname;privateintage;publicdouble[]scores;publicStudent(Stringsno,Stringname,intage,double[]scor{undefinedthis.name=name;this.scores=score;this.age=age;this.sno=sno;}publicdoubleavgScore(){undefineddoubletotal=0;for(inti=0,len=scores.length;i publicvoidoutputInfo(){undefinedSysteout.println('学号“+sno+”姓名'+name+'年龄'+ag;} }//类CollegeStudent大学生 publicclassCollegeStudentextendsStudent{undefinedprivatedoubledy;privatedoublety;privatedoublemy;publicCollegeStudent(Stringsno,Stringname,intage,double[]score,doubledy,doublety,doublemy){undefinedsuper(sno,name,age,scor;this.dy=dy;this.ty=ty;this.my=my;}publicdoublecalScore(){undefinedreturnavgScore()+dy+ty+my;}publicstaticvoidmain(String[]args){undefineddouble[]score={100,100,100,100,100};CollegeStudentcollegeStudent=newCollegeStudent(“06411100”,“张三”,20,score,100.0,100.0,100.0);collegeStudent.outputInfo();Systeout.println('平均成绩'+collegeStudent.avgScore());Systeout.println('综合成绩'+collegeStudent.calScore());}} 文章为作者独立观点,不代表 股票程序化软件自动交易接口观点