-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
39 lines (32 loc) · 862 Bytes
/
Copy pathStudent.java
File metadata and controls
39 lines (32 loc) · 862 Bytes
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
package set;
import java.util.Objects;
public class Student implements Comparable<Student> {
private String name;
private int course;
public Student(String name, int course) {
this.name = name;
this.course = course;
}
@Override
public int compareTo(Student o) {
return (this.course-o.course);
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", course=" + course +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Student student = (Student) o;
return course == student.course;
}
@Override
public int hashCode() {
return Objects.hash(course);
}
}