My homework is to create an equal method of a class that override Object class's equal method in Java. I have coded like below but the lecturer commented that: "doubles cannot be compared for equality with ==,!= as storage is not exact." So how do I edit the code accordingly in this case? Thank you very much. class GameSettings {
private int firingInterval;
private double moveSpeed;
...
public boolean equals(Object obj) {
//objects are equal if same firingInterval and moveSpeed
GameSettings other;
boolean result = false;
//TODO
other = (GameSettings) obj;
if (obj instanceof GameSettings) {
return (firingInterval == other.getFiringInterval()
&& moveSpeed == other.getMoveSpeed());
} else {
return result;
}
}