Java Reference
In-Depth Information
2. Enter lines 32 through 51 as shown in Figure 10-35.
TextPad displays code for the accessor methods in the coding window
(Figure 10-37). Note that access to attributes of the Password class is
provided through accessor methods in the Password class.
accessor
methods
calls to Password class accessor methods
FIGURE 10-37
3. Enter lines 52 through 68 as shown in Figure 10-35. Save and compile
the User class.
TextPad displays code for the validate() and changePassword() methods in
the coding window (Figure 10-38). Again, because the Password instance
variable is declared private, several public methods of the User class are
needed to call corresponding methods in the Password class. When chang-
ing the password, any PasswordExpiredException is caught and ignored,
and the password is set to the new value entered by the user. Any other
exception prevents the change from occurring.
added methods
to validate the
password, set
password to new
value, and catch
exception
PasswordExpiredException
caught and ignored
FIGURE 10-38
The User class now is complete and available for use with the application.
 
Search WWH ::




Custom Search