日期:2014-05-20 浏览次数:20898 次
package test;
public class Student {
// 学号、姓名、英语成绩、数学成绩、计算机成绩。
String number;
String name;
int engScore;
int mathScore;
int compScore;
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getEngScore() {
return engScore;
}
public void setEngScore(int engScore) {
this.engScore = engScore;
}
public int getMathScore() {
return mathScore;
}
public void setMathScore(int mathScore) {
this.mathScore = mathScore;
}
public int getCompScore() {
return compScore;
}
public void setCompScore(int compScore) {
this.compScore = compScore;
}
public Student(){}
public Student(
String number,
String name,
int engScore,
int mathScore,
int compScore) {
this.setName(name);
this.setNumber(number);
this.setCompScore(compScore);
this.setEngScore(engScore);
this.setMathScore(mathScore);
}
public int sum(
int engScore,
int mathScore,
int compScore) {
int sum = engScore + compScore + mathScore;
System.out.println(sum);
return sum;
}
public String compare(int a, int b) { //你可以在main里面分别调用sum(....);分别得到总数,然后再调用此方法!
if(a > b) {
return "大于";
} else if(a < b) {
return "小于";
} else {
return "等于";
}
}
public int testScore(
int engScore,
int mathScore,
int compScore) {
int sum = this.sum(engScore, mathScore, compScore);
return sum/3;
}
}