import java.util.Objects;
public class Student implements Comparable<Student> {private int sno;private String name;private int age;private int math;private int chinese;private int english;private int assemble;public Student(int sno, String name, int math, int chinese, int english) {this.sno = sno;this.name = name;this.math = math;this.chinese = chinese;this.english = english;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public int getSno() {return sno;}public void setSno(int sno) {this.sno = sno;}public int getChinese() {return chinese;}public void setChinese(int chinese) {this.chinese = chinese;}public int getMath() {return math;}public void setMath(int math) {this.math = math;}public int getEnglish() {return english;}public void setEnglish(int english) {this.english = english;}public int getAssemble(){return this.chinese+this.math+this.english;}@Overridepublic String toString() {return this.sno+" "+this.name+" "+this.chinese+" "+this.math+" "+this.english+" "+this.getAssemble();}@Overridepublic int compareTo(Student s) {if (this.getAssemble() == s.getAssemble()){return this.sno-s.sno;}else {return this.getAssemble()-s.getAssemble()>0?-1:1;}}}
import java.util.*;public class Main {public static void main(String[] args) {Student s1 = new Student(101,"Zhang",78,87,86);Student s2 = new Student(102,"Wang",91,88,90);Student s3 = new Student(103,"Li",75,92,84);TreeSet<Student> ts = new TreeSet<>();ts.add(s1);ts.add(s2);ts.add(s3);for (Student t : ts) {System.out.println(t);}}
}