-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
40 lines (32 loc) · 1.04 KB
/
Copy pathStudent.java
File metadata and controls
40 lines (32 loc) · 1.04 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
package map;
import java.util.Objects;
public class Student implements Comparable<Student>{
public String name;
public String surName;
public int course;
public Student(String name, String surName, int course) {
this.name = name;
this.surName = surName;
this.course = course;
}
@Override
public String toString() {
return (String.format("(%s %s course-%d)", name, surName, 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 && Objects.equals(name, student.name) && Objects.equals(surName, student.surName);
}
@Override
public int hashCode() {
return Objects.hash(name, surName, course);
// return (name.length()*7 + surName.length()*11 + course*53);
}
@Override
public int compareTo(Student o) {
return this.surName.compareTo(o.surName);
}
}