Using if/else statements in setters

218 views Asked by At

in my UML it is telling me to not let the field update if the value is negative

public void setCurrentBalance(double currentBalance)
{
    if (currentBalance <= 0)
        this.currentBalance = currentBalance;
    else
        this.currentBalance = currentBalance;
}

Does this look correct if my constructor looks like:

    setAccountNumber(accountNumber);
    setOwnerFirstName(ownerFirstName);
    setOwnerLastName(ownerLastName);
    setCurrentBalance(currentBalance);
    setMinimumBalanceRequired(minimumBalanceRequired);
0

There are 0 answers