Java Reference
In-Depth Information
overage is amount
by which current
password history list
size exceeds max
history limit
mutator method
not done if
max history
limit not
exceeded
FIGURE 9-23
Setting the maximum size of the password history less than the current size
might be done rarely, if at all. The mutator method, setMaxHistory(), must
ensure that the number of passwords stored in the history never is more than
the maximum size. To do so, any excess entries in the history must be removed,
beginning with the oldest entry.
Coding Accessor Methods for Read-Only Attributes
As shown in the previous section, accessor and mutator methods often are
coded successively, so it is obvious to the programmer when they exist in pairs.
Some attributes, however, have an accessor method, but no mutator method.
These attributes sometimes are called read-only attributes, because the user can
obtain their value but cannot change it, effectively providing read-only access to
the attributes.
Figure 9-24 displays the code for the accessor methods to read-only values
for the Password class.
114
public int getRemainingUses ()
115
{
116
return remainingUses;
117
}
118
119
public int getHistorySize ()
120
{
121
return pswdHistory.size () ;
122
}
FIGURE 9-24
Search WWH ::




Custom Search