package homework;
public class Student implements Comparable<Student>{
private int sno;
private String sname;
private String gender;
private double score;
public int getSno() {
return sno;
}
public void setSno(int sno) {
this.sno = sno;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public Student(int sno, String sname, String gender, double score) {
super();
this.sno = sno;
this.sname = sname;
this.gender = gender;
this.score = score;
}
public Student() {
}
@Override
public String toString() {
return "Student [sno=" + sno + ", sname=" + sname + ", gender=" + gender + ", score=" + score + "]";
}
@Override
public int compareTo(Student o) {
if(o.getScore() == this.score) {
return o.getSno() - sno;
}else if(o.getScore() > this.score) {
return 1;
}else {
return -1;
}
}
}
菜单功能实现: