📄 student.java
字号:
package exec.day1002.exam;
import java.util.*;
/**
* Student类 学生类
* 属性:姓名 一张答卷 一张考卷
* @author new
*/
public class Student implements Comparable {
private String name;//姓名
private AnswerSheet answerSheet;//答卷
private Paper paper;//考卷
private int score;//分数
public Student(String name, AnswerSheet answerSheet, Paper paper) {
super();
this.name = name;
this.answerSheet = answerSheet;
this.paper = paper;
}
public int hashCode(){
return name.hashCode();
}
public int compareTo(Object obj){
Student s = (Student)obj;
//按照分数排序,分数相同时,按照姓名排序
if(s.score==this.score){
return this.name.compareTo(s.name);
}
return this.score-s.score;
}
public boolean equals(Object obj){
if(obj==this){
return true;
}
if(obj==null){
return false;
}
if(!(obj instanceof Student)){
return false;
}
Student s = (Student)obj;
if(s.name.equals(this.name)){
return true;
}
return false;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public AnswerSheet getAnswerSheet() {
return answerSheet;
}
public String getName() {
return name;
}
public Paper getPaper() {
return paper;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -