package Test;
public class Student implements Comparable<Student>{
private int score;
private int age;
private String name;
public Student() {
super();
}
public Student( String name, int age,int score) {
super();
this.score = score;
this.age = age;
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Student [score=" + score + ", age=" + age + ", name=" + name+ "]";
}
public int compareTo(Student s){
int num = s.score - this.score;
int num1 = num==0?(this.age - s.age):num;
int num2 = num1==0?s.name.compareTo(this.name):num1;
return num2;
}
}
|
|