Java Reference
In-Depth Information
124
public boolean
isExpiring
()
125
{
126
boolean
expiring =
false
;
127
128
if
(
autoExpires && remainingUses <= expiresNotifyLimit
)
129
expiring =
true
;
130
131
return
expiring;
132
}
FIGURE 9-25
The following steps enter code for the read-only accessor methods for the
Password class.
To Code Read-Only Accessor Methods
1.
Enter lines 114 through 117 as shown in Figure 9-24 on page 563.
TextPad displays the getRemainingUses() accessor method that provides
read-only access to an instance variable, remainingUses (Figure 9-26).
Because remainingUses is a read-only attribute, no corresponding mutator
methods exist.
accessor
method for
read-only
variable,
remainingUses
instance
variable
FIGURE 9-26
2.
Enter lines 119 through 122 as shown in Figure 9-24.
TextPad displays the getHistorySize() method, which calls the size() accessor
method of the ArrayList object (Figure 9-27). The size() method functions as
a type of read-only accessor method for ArrayList objects.
accessor
method for
read-only data
call to ArrayList
accessor method, size()
(continued)
FIGURE 9-27
Search WWH ::
Custom Search