done
This commit is contained in:
@@ -41,30 +41,27 @@ public class Student {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
// TODO:
|
||||
// Return custom hash
|
||||
return id % 97;
|
||||
|
||||
// Example:
|
||||
// return id % 97;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
// TODO:
|
||||
if(obj == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
// Step 1:
|
||||
// Check null
|
||||
Student std = (Student) obj;
|
||||
|
||||
// Step 2:
|
||||
// Convert obj to Student
|
||||
if(std.hashCode() == this.hashCode()){
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Step 3:
|
||||
// Compare IDs
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user