java 测试题,紧急!
发布网友
发布时间:2022-04-25 01:20
我来回答
共2个回答
热心网友
时间:2023-10-19 08:25
public class student
{
int snum;//xuehao
String name;
int escore;//englishscore;
int mscore;
int cscore;//computerscore;
public void setsnum(int snum){this.snum=snum;}
public void setname(String name){this.name=name;}
public void setescore(int escore){this.escore=escore;}
public void setmscore(int mscore){this.escore=escore;}
public void setcscore(int cscore){this.escore=escore;}
public int getsnum(){return snum;}
public String getname(){return name;}
public int getscore(){return escore;}
public int getmcore(){return mscore;}
public int getccore(){return cscore;}
public student(int snum,String name,int escore,int mscore,int cscore)
{
this.setsnum(snum);
this.setname(name);
this.setescore(escore);
this.setmscore(escore);
this.setcscore(escore);
}
public String toString()
{return "snum="+snum+"\t name="+name+"\t escore"+escore+"\t mscore"+mcore+"\t cscore"+cscore;}
public int sum(student e)
{return e.getescore()+e.getmscore()+e.getcscore();}
public String compare(Student e1 ,student e2)
{if(e1.sum()==e2.sum())return "等于";
else retuen (e1.sum()>e2.sum())?"大于":"小于";}
public float testscore(student e)
{return (e.getescore()+e.getmscore()+e.getcscore())/3;}
public static voia main(String args[])
{
student stu=new student(1,"1",2,3,4);
studentxw sxw=new studentxw(1,"1",2,3,4,"work");
studentxw sbz=new studentbz(1,"1",2,3,4,"work1");
}
}
class studentxw extends student
{
private String work;
public void setwork(String work){this.work=work;}
public String getwork(){return work;}
public studentxw(int snum,String name,int escore,int mscore,int cscore,String work)
{
super(snum,name,escore,mscore,cscore);
this.setwork(work);
}
public float testscore(student e)
{return super.test(e)+3;}
}
class studentbz extends student
{
private String work;
public void setwork(String work){this.work=work;}
public String getwork(){return work;}
public studentxw(int snum,String name,int escore,int mscore,int cscore,String work)
{
super(snum,name,escore,mscore,cscore);
this.setwork(work);
}
public float testscore(student e)
{return super.test(e)+5;}
}
热心网友
时间:2023-10-19 08:25
这个好写啊,但是没时间。
你先写个Student类,2和3分别继承Student类。第四个就是个Driver。
public class StudentXW extends Student{
private String responsibility;
}
public class StudentBZ extends Student{
private String responsibility;
}