-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
62 lines (48 loc) · 1.29 KB
/
Student.java
File metadata and controls
62 lines (48 loc) · 1.29 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
public class Student implements Comparable<Student> {
private String studentId;
private String grade;
private String name;
private String course;
public Student(String studentId, String name, String course, String grade) {
this.studentId = studentId;
this.name = name;
this.course = course;
this.grade = grade;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
@Override
public String toString() {
return studentId + " " + name + " " + course + " " + grade;
}
@Override
public int compareTo(Student that) {
int gradeComparison = that.grade.compareTo(this.grade);
if (gradeComparison == 0) {
return this.name.compareTo(that.name);
}
return gradeComparison;
}
}