Download Set_advanced_project/Set_module/src/TreeSet_package3/Student.java from zxy0307/Java: direct link, hf CLI and curl.
- Browser
- Download file 2.02 kB
-
https://huggingface.co/zxy0307/Java/resolve/main/Set_advanced_project/Set_module/src/TreeSet_package3/Student.java
- Command line
-
hf download hf://zxy0307/Java/Set_advanced_project/Set_module/src/TreeSet_package3/Student.java
-
curl -L -o Student.java https://huggingface.co/zxy0307/Java/resolve/main/Set_advanced_project/Set_module/src/TreeSet_package3/Student.java
2.02 kB
| package TreeSet_package3; | |
| public class Student implements Comparable<Student> { | |
| //姓名 | |
| private String name; | |
| //年龄 | |
| private int age; | |
| //语文成绩 | |
| private int chinese; | |
| //数学成绩 | |
| private int math; | |
| //英语成绩 | |
| private int english; | |
| public Student() { | |
| } | |
| public Student(String name, int age, int chinese, int math, int english) { | |
| this.name = name; | |
| this.age = age; | |
| this.chinese = chinese; | |
| this.math = math; | |
| 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 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 String toString() { | |
| return "Student{" + | |
| "name='" + name + '\'' + | |
| ", age=" + age + | |
| ", chinese=" + chinese + | |
| ", math=" + math + | |
| ", english=" + english + | |
| '}'; | |
| } | |
| public int compareTo(Student o) { | |
| int sum1 = this.chinese + this.math + this.english; | |
| int sum2 = o.getChinese() + o.getMath() + o.getEnglish(); | |
| int i = sum1 - sum2; | |
| i = i == 0 ? this.getChinese() - o.getChinese() : i; | |
| i = i == 0 ? this.getMath() - o.getMath() : i; | |
| i = i == 0 ? this.getEnglish() - o.getEnglish() : i; | |
| i = i == 0 ? this.getAge() - o.getAge() : i; | |
| i = i == 0 ? this.getName().compareTo(o.getName()) : i; | |
| return i; | |
| } | |
| } | |