Here's a class named BlackBox. It overrides the equals and hashCode methods.
Which restrictions for the equals method are met?
public class BlackBox {
private final int additive;
private int input1;
private int input2;
public BlackBox(int add){
additive = add;
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) return false;
if (obj == null || !(obj instanceof BlackBox)) return false;
BlackBox that = (BlackBox) obj;
return additive == that.additive
&&
input1 == that.input1
&&
input2 == that.input2;
}
}