Counter class (cont.)
n
Adding a method
decrementCount
threatens the class invariant constraint
that
tally
be greater than or equal to
zero.
n
n
public void
decrementCount () {
n
tally = tally - 1;
n
}
n
We must guard the assignment
statement with a condition statement.