(Creating Custom Exception Class) Write a Password class that stores a password string

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 3GZ
icon
Related questions
Question

(Creating Custom Exception Class) Write a Password class that stores a password string. Passwords must contain at least seven alpha-numeric characters, with at least one letter and one digit. Also write an InvalidPasswordException class that extends Exception. The  Password constructor should throw an InvalidPasswordException, which should report an appropriate message based on a given string (e.g. if the string contains no digits, the exception should report this fact). 
 
Use java swing to write a GUI program to prompt the user to enter a password and report an InvalidPasswordException if an invalid password is entered. Some sample screenshots are shown below:

Set Password
Enter your password
Submit
Your password should have at least 1 digit.
Your password should have at least 7 alpha-numeric
characters.
Set Password
Enter your password
Submit
Congratulations! Your password is valid.
Transcribed Image Text:Set Password Enter your password Submit Your password should have at least 1 digit. Your password should have at least 7 alpha-numeric characters. Set Password Enter your password Submit Congratulations! Your password is valid.
Set Password
Enter your password
Submit
Invalid password: password cannot be null or an empty string
Set Password
O X
Enter your password
Submit
Your password should have at least 1 letter.
Transcribed Image Text:Set Password Enter your password Submit Invalid password: password cannot be null or an empty string Set Password O X Enter your password Submit Your password should have at least 1 letter.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT