public class PasswordGeneratorAndStorage

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

code:

public class PasswordGeneratorAndStorage {

/**
* Adds an application to the applications ArrayList. If index is -1, add application
* to the end of applications. Else is index is within the size of applications, add
* application at that index in applications. Otherwise, return. However, if applications
* or application is null, return.
*
* @param applications
* @param application
* @param index
*/
public static void addApplication(ArrayList<String> applications, String application, int index) {
// TODO: FILL IN BODY
}

/**
* Generates a random password of length passwordLength and adds it to the end of
* passwords if index is -1, or adds it to the index of passwords if index is within the
* size of passwords (similar to how the addApplication adds an application). To generate
* the random password, use rand to generate a random int within the size of characters. You
* can then use this int to grab the char at that index in characters and concatenate that
* to your String password variable. However, if passwords is null, return.
*
* @param passwords
* @param passwordLength
* @param rand
* @param index
* @param characters
*/
public static void addPassword(ArrayList<String> passwords, int passwordLength, Random rand, int index, String characters) {
// TODO: FILL IN BODY
}

/**
* Removes a password from your password storage parallel ArrayLists. To do this, remove the
* first instance (starting from index 0 of applications) of application in applications. Then
* remove its corresponding password in passwords. If there are duplicate application/password
* pairs (ie two Facebook passwords) you should only remove the first instance. However, if
* applications or passwords are null, return.
*
* @param applications
* @param passwords
* @param application
*/
public static void removePassword(ArrayList<String> applications, ArrayList<String> passwords, String application) {
// TODO: FILL IN BODY
}

/**
* Generates a String with a display message for your applications and passwords,
* where the passwords are in star notation (every character in the password is
* replaced with '*'). The start of your message should be "Your Passwords:\n".
* Return "You do not have any passwords in storage!\n" if applications is null or
* empty or passwords is null or empty.
* Note: your generated String should end with a single '\n'.
* Example:
* Your Passwords:
* Canvas: ********
* Piazza: *************
*
* @param applications
* @param passwords
* @return the display message
*/
public static String getDisplayString(ArrayList<String> applications, ArrayList<String> passwords) {
// TODO: FILL IN BODY
}

public static void main(String[] args) {
// TODO: FILL IN BODY
}
}

 

Example method arguments:
// passwords = [], passwordLength = 8, rand, index = -1, characters = Config.CHARACTERS
// passwords = ["hkkAh6UU"], passwordLength = 16, rand, index = -1, characters = Config.CHARACTERS
Example resulting passwords ArrayLists:
// passwords =
// passwords = ["hkkAh6UU", "hB2f4ZA9Ug7Ljq7E"]
נ" hkkAh"]6UU
3. (removePassword) Removes a password from passwords and its corresponding application from applications
Find the first instance of application in applications (starting from index 0).
• Remove the application stored at that index in applications (case sensitive).
• Remove the password stored at that index in passwords (case sensitive).
• However, if applications or passwords or application are null, return.
Example method arguments:
// applications
= [Instagram, Facebook, Canvas, Google], passwords = [U340pq0Z1A1L50v1Cq6M1ET7,
hkkAh6UU, 9HEAÇE2T, hB2f4ZA9Ug7Ljq7E], and application = "Google"
// applications = [Instagram, Facebook, Canvas], passwords = [U340pg0Z1A1L50v1Cq6M1ET7, hkkAh6UU,
9HEAQE2T], and application = "Piazza"
Example resulting applications ArrayLists:
// applications
[Instagram, Facebook, Canvas] and passwords = [U340pg0Z1A1L50v1Cq6M1ET7,
%3D
hkkAh6UU, 9HEA¤E2T]
// applications
[Instagram, Facebook, Canvas] and passwords =
[U340pg0Z1A1L50v1cq6M1ET7,
%3D
hkkAh6UU, 9HEA¤E2T]
4. (getDisplayString) Create a String for displaying your password storage parallel ArrayLists
• The start of your String should be "Your Passwords:\n".
• For each application, password pair, concatenate the application and password in this format: "application: ********\n' where each
character in your password should be replaced with a *.
• However, if applications is null or empty or passwords is null or empty, return "You do not have any passwords in storage!\n"
Example method arguments:
// applications = [Instagram, Canvas] and passwords =
[U340pg0Z1A1L50v1Cq6M1ET7, 9hEAqE2T]
Example resulting String:
Transcribed Image Text:Example method arguments: // passwords = [], passwordLength = 8, rand, index = -1, characters = Config.CHARACTERS // passwords = ["hkkAh6UU"], passwordLength = 16, rand, index = -1, characters = Config.CHARACTERS Example resulting passwords ArrayLists: // passwords = // passwords = ["hkkAh6UU", "hB2f4ZA9Ug7Ljq7E"] נ" hkkAh"]6UU 3. (removePassword) Removes a password from passwords and its corresponding application from applications Find the first instance of application in applications (starting from index 0). • Remove the application stored at that index in applications (case sensitive). • Remove the password stored at that index in passwords (case sensitive). • However, if applications or passwords or application are null, return. Example method arguments: // applications = [Instagram, Facebook, Canvas, Google], passwords = [U340pq0Z1A1L50v1Cq6M1ET7, hkkAh6UU, 9HEAÇE2T, hB2f4ZA9Ug7Ljq7E], and application = "Google" // applications = [Instagram, Facebook, Canvas], passwords = [U340pg0Z1A1L50v1Cq6M1ET7, hkkAh6UU, 9HEAQE2T], and application = "Piazza" Example resulting applications ArrayLists: // applications [Instagram, Facebook, Canvas] and passwords = [U340pg0Z1A1L50v1Cq6M1ET7, %3D hkkAh6UU, 9HEA¤E2T] // applications [Instagram, Facebook, Canvas] and passwords = [U340pg0Z1A1L50v1cq6M1ET7, %3D hkkAh6UU, 9HEA¤E2T] 4. (getDisplayString) Create a String for displaying your password storage parallel ArrayLists • The start of your String should be "Your Passwords:\n". • For each application, password pair, concatenate the application and password in this format: "application: ********\n' where each character in your password should be replaced with a *. • However, if applications is null or empty or passwords is null or empty, return "You do not have any passwords in storage!\n" Example method arguments: // applications = [Instagram, Canvas] and passwords = [U340pg0Z1A1L50v1Cq6M1ET7, 9hEAqE2T] Example resulting String:
9.13 ***zyLab: Password Generator and Storage
The goal of this program is to practice creating and updating parallel ArrayLists as well as becoming more comfortable with iterating
through them and displaying their contents.
You will create a random password generator that stores the generated passwords in parallel ArrayLists: one for the password and one for
its corresponding application (eg Canvas and the password for Canvas). You will also create functionality to remove password/application
pairs you no longer want to store in your parallel ArrayLists, and you will create functionality to safely display your passwords to the console
by display (eg "***********" instead of "password123").
1. (addApplication) Add an application to the applications
• If index is -1, add application to the end of applications. Else if index is within the size of applications, then add application to that
index in applications. Otherwise, return.
• However, if applications or application is null, return.
Example method arguments:
["Facebook", "Google"], application = "Canvas", and index = 1
// applications =
// applications =
["Facebook", "Google"], application = "Canvas", and index = -1
Example resulting applications ArrayLists:
// applications = ["Facebook", "Canvas", "Google"]
// applications = ["Facebook", "Google", "Canvas"]
2. (addPassword) Add a randomly generated password to passwords
• Create a String password that is of length passwordLength. You can do this by using concatenation. Each character you concatenate
should be randomly selected from the specified characters array. If this array is length 10, then generating a random number between
O and 9 will result in a 'random' letter for the password.
• If index is -1, add password to the end of passwords. Else if index is within the size of passwords, then add password to that index in
passwords.
• However, if passwords is null, return.
Example method arguments:
// passwords = [], passwordLength = 8, rand, index = -1, characters = Config.CHARACTERS
// passwords = ["hkkAh6UU"], passwordLength = 16, rand, index = -1, characters = Config.CHARACTERS
Example resulting passwords ArrayLists:
// passwords =
// passwords = ["hkkAh6UU", "hB2f4ZA9Ug7Ljq7E"]
["hkkAh6UU"]
Transcribed Image Text:9.13 ***zyLab: Password Generator and Storage The goal of this program is to practice creating and updating parallel ArrayLists as well as becoming more comfortable with iterating through them and displaying their contents. You will create a random password generator that stores the generated passwords in parallel ArrayLists: one for the password and one for its corresponding application (eg Canvas and the password for Canvas). You will also create functionality to remove password/application pairs you no longer want to store in your parallel ArrayLists, and you will create functionality to safely display your passwords to the console by display (eg "***********" instead of "password123"). 1. (addApplication) Add an application to the applications • If index is -1, add application to the end of applications. Else if index is within the size of applications, then add application to that index in applications. Otherwise, return. • However, if applications or application is null, return. Example method arguments: ["Facebook", "Google"], application = "Canvas", and index = 1 // applications = // applications = ["Facebook", "Google"], application = "Canvas", and index = -1 Example resulting applications ArrayLists: // applications = ["Facebook", "Canvas", "Google"] // applications = ["Facebook", "Google", "Canvas"] 2. (addPassword) Add a randomly generated password to passwords • Create a String password that is of length passwordLength. You can do this by using concatenation. Each character you concatenate should be randomly selected from the specified characters array. If this array is length 10, then generating a random number between O and 9 will result in a 'random' letter for the password. • If index is -1, add password to the end of passwords. Else if index is within the size of passwords, then add password to that index in passwords. • However, if passwords is null, return. Example method arguments: // passwords = [], passwordLength = 8, rand, index = -1, characters = Config.CHARACTERS // passwords = ["hkkAh6UU"], passwordLength = 16, rand, index = -1, characters = Config.CHARACTERS Example resulting passwords ArrayLists: // passwords = // passwords = ["hkkAh6UU", "hB2f4ZA9Ug7Ljq7E"] ["hkkAh6UU"]
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY