Professional Documents
Culture Documents
Assigment
Assigment
You are required to write a complete Java code for class PasswordStorage class. Details of
PasswordStorage class as shown in Figure 1. In all cases, special characters should be limited
to '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_' and '-' character only.
Constructor
PasswordStorage (String userName, String password, String URL)
Construct new PasswordStorage with provided user name, password and URL.
PasswordStorage (String userName, String URL)
Construct new PasswordStorage with provided user name and URL. Password should be generated
automatically. Password should consists of exactly 12 characters, has AT LEAST ONE digit, ONE
lower case alphabet, ONE upper case alphabet and ONE special character
Method Summary
Modifier and Method and Description
Return Type
String getUserName()
return current user name.
String getPassword()
return current password.
String getURL()
return current URL.
void setNewUserName(String newUserName)
set user name to newUserName
void setNewPassword(String newPassword)
set password to newPassword
void setNewPassword(int passwordLength)
set password to randomly create password consists of paswordLength
characters (minimum 8 characters password). The created password also need
to include AT LEAST ONE digit, ONE lower case alphabet, ONE upper case
alphabet and ONE special character
void setNewURL(String newURL)
set URL to newURL.
static String generateRandomPassword(int length, boolean containDigit, boolean
containUpper, boolean containLower, boolean containSpecial)
return a randomly created password with length number of characters. However,
minimum password length must be 8 characters. The created password should:-
i. contain at least one digit if containDigit is True,
ii. contain at least one upper case alphabet if containUpper is True,
iii. contain at lease one lower case alphabet if containLower is True and
iv. contain at least on special character if containSpecial is True.
static String passwordStrength(String password )
return the strength of the password. The strength of the password is determine
based on point system and as follows:
i. password is “Weak” if total point is less than 5
ii. password is “OK” if total point is between 5 and 6
iii. password is “Good” if total point is 7 and 8
iv. password is “Strong” if total point is more than 9
String toString()
an overriden method that return String representation of the object. Given the
following code:-
It should be noted that, you can have as many private instances and methods as you want.