编写学生类 Student,属性有学号(int id)、姓名(String name)、语文成绩(double chinese)、数学成绩(double math)、总分(double total)、平局分(double aver)。总分、平局是计算出来的。类的方法包括构造方法、计算总分、平局分、及set和get属性方法。并编写测试类进行测试。
package bhvgg;
public class DENO {
private int id;
private String name;
private double chinese;
private double math;
private double total;
private double aver;
public DENO() {
}
public DENO(int id,String name,double chinese,double math) {
this.id= id;
this.name=name;
this.chinese=chinese;
this.math=math;
}
@Override
public String toString() {
return "Student{"+
"id="+id+
",name=' " + name + '\''+
",math=" +math +
",total=" +total +
",aver=" + aver +
"";}
public int getId() {
return id;
}
public void setId(int id) {
this.id =id;
}
public String getName() {
return name;
}
public void SETName(String name) {
this.name = name;
}
public double getChinese() {
return chinese;
}
public void setChinese(double chinese) {
this.chinese =chinese;
}
public double getMath() {
return math;
}
public void setMath(double math) {
this.math = math;
}
public double getTotal() {
return total;
}
public void setTotal(double total) {
this.total = total;
}
public double getAver() {
return aver;
}
public void setAver(double aver) {
this.aver = aver;
}
public void sum() {
this.total = this.chinese+this.math;
}
public void ave() {
this.aver = (this.chinese+this.math)/2;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}