用JAVA构建一个Student 方法应怎么做?
- 提问者网友:箛茗
- 2021-04-22 21:05
- 五星知识达人网友:枭雄戏美人
- 2021-04-22 22:44
我直接给你一个Student 类,里面有Student 方法:
public class Student {
private String name ;
private int computer_score;
private int English_score;
private int Maths_score;
public Student(String name,int computer_score,int English_score,int Maths_score){
this.name=name;
this.computer_score = computer_score;
this.English_score=English_score;
this.Maths_score = Maths_score;
}
public void setName(String name){
this.name=name;
}
public void setComputer_score(int computer_score){
this.computer_score=computer_score;
}
public void setEnglish_score(int English_score ){
this.English_score = English_score;
}
public void setMaths_score(int Maths_score ){
this.Maths_score = Maths_score;
}
public int getTotalScore( ){
return this.computer_score+this.English_score+this.Maths_score;
}
public void introduce ( ){
System.out.print("姓名:"+this.name+",总成绩为:"+getTotalScore());
}
}