-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathStudent.java
More file actions
80 lines (66 loc) · 1.49 KB
/
Student.java
File metadata and controls
80 lines (66 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.examplehub.domain;
public class Student implements Comparable<Student> {
private int id;
private int Chinese;
private int math;
int english;
public Student() {}
public Student(int id, int chinese, int math, int english) {
this.id = id;
Chinese = chinese;
this.math = math;
this.english = english;
}
public int getTotal() {
return this.getChinese() + this.getMath() + this.getEnglish();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getChinese() {
return Chinese;
}
public void setChinese(int chinese) {
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;
}
@Override
public int compareTo(Student o) {
if (this.getTotal() != o.getTotal()) {
return this.getTotal() - o.getTotal();
} else if (this.getChinese() != o.getChinese()) {
return this.getChinese() - o.getChinese();
} else if (this.getMath() != o.getMath()) {
return this.getMath() - o.getMath();
} else {
return this.getMath() - o.getMath();
}
}
@Override
public String toString() {
return "Student{"
+ "id="
+ id
+ ", Chinese="
+ Chinese
+ ", math="
+ math
+ ", english="
+ english
+ '}';
}
}