-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
46 lines (37 loc) · 1.09 KB
/
Copy pathStudent.java
File metadata and controls
46 lines (37 loc) · 1.09 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
package Lab6;
public class Student {
private int studentID;
private String studentName;
private String major;
public Student(int studentID, String studentName, String major) {
this.studentID = studentID;
this.studentName = studentName;
this.major = major;
}
public int getStudentID() {
return studentID;
}
public String getStudentName() {
return studentName;
}
public String getMajor() {
return major;
}
public String toString(){
return "Student name: " + studentName + "\nStudent ID: " +studentID + "\nMajor: " + major;
}
public boolean equals(Object obj){
if(this == obj){
return true;
}
else if(obj == null) return false;
if(!(obj instanceof Student)) return false;
Student student = (Student)obj;
if(student.getStudentID() != this.getStudentID()) return false;
return true;
}
@Override
public int hashCode() {
return Integer.hashCode(studentID);
}
}