As per an assignment, I have to create a method called "equals" to do the following:
The method compares the instance variables of the calling object with instance variables of the parameter object for equality and returns
true
if the dollars and the cents of the calling object are the same as the dollars and the cents of the parameter object. Otherwise, it returnsfalse
.
UPDATE: I made a mistake and put the wrong thing, updated it. Got a new error:
Money.java:115: error: long cannot be dereferenced
if (dollars.equals(otherObject.dollars) &&
^
Money.java:116: error: long cannot be dereferenced
cents.equals(otherObject.cents))
^
2 errors
With the method:
public boolean equals(Money otherObject)
{
boolean status;
if (dollars.equals(otherObject.dollars) &&
cents.equals(otherObject.cents))
return status = true;
else
return status = false;
}