Runtime

Use the password generator here

Video submission

I'm not allowed to post the video anywhere :(

Write-up

Submit responses to prompts 3a – 3d, which are described below. Response to all prompts combined must not exceed 750 words (program code is not included in the word count).

3a.

Provide a written response that does all three of the following:

Approx. 150 words (for all subparts of 3a combined)

i. Describes the overall purpose of the program.

The purpose of the program is to generate secure and unique passwords in an efficient manner while also offering customization options to the user.

ii. Describes what functionality of the program is demonstrated in the video.

The video shows a user testing the error-handling of the program by trying invalid inputs. Then, the user operates the program as intended and generates several unique passwords while customizing the length and content of each one.

iii. Describes the input and output of the program demonstrated in the video.

The inputs in the video are the user typing in the preferred password length, selecting or deselecting certain content preferences, and clicking the button to generate the password. The outputs are passwords that are generated and/or error messages that are presented.

3b.

Capture and paste two program code segments you developed during the administration of this task that contain a list (or other collection type) being used to manage complexity in your program.

Approx. 200 words (for all subparts of 3b combined, exclusive of program code)

i. The first program code segment must show how data have been stored in the list.

code1

ii. The second program code segment must show the data in the same list being used, such as creating new data from the existing data or accessing multiple elements in the list, as part of fulfilling the program's purpose.

code2

Then, provide a written response that does all three of the following:

iii. Identifies the name of the list being used in this response.

The name of the collection is "chars".

iv. Describes what the data contained in the list represent in your program.

The data in "chars" represents all characters that can be used by the program while generating a password.

v. Explains how the selected list manages complexity in your program code by explaining why your program code could not be written, or how it would be written differently, if you did not use the list.

"chars" is a dictionary that manages complexity by storing characters based on their format (i.e. capital letters, lowercase letters, numbers, and symbols). This is essential to the complexity of the program because it makes it very efficient to identify which types of characters are allowed when generating a password, based on which content preferences the user has selected. It does this by concatenating all of the allowed characters into an indexable string "selectedChars", which is made up of the selected character types that can be accessed in "chars". An alternative way of identifying the allowed characters would be to store all characters in existence as separate items in an array, then categorizing each one based on its format to then be sorted into a collection of filtered characters. However, this is more complex because it would take many more processes to filter each item into a category based on it's format, whereas "chars" already stores the data that way while making it much more accessible.

3c.

Capture and paste two program code segments you developed during the administration of this task that contain a student-developed procedure that implements an algorithm used in your program and a call to that procedure.

Approx. 200 words (for all subparts of 3c combined, exclusive of program code)

i. The first program code segment must be a student-developed procedure that:- Defines the procedure's name and return type (if necessary)- Contains and uses one or more parameters that have an effect on the functionality of the procedure

  • Implements an algorithm that includes sequencing, selection and iteration

code3

ii. The second program code segment must show where your student-developed procedure is being called in your program.

code4

Then, provide a written response that does both of the following:

iii. Describes in general what the identified procedure does and how it contributes to the overall functionality of the program.

The procedure here is called "generate". It takes in a parameter of "passwordLen", which is the desired password length that's inputted by the user. The procedure checks which content settings the user has selected, then checks if the inputted length is valid through a process of selection with an if-statement. Finally, it randomly generates a string of characters that is of the desired length and content using if-statements and a for-loop. This contributes to the overall functionality of the program because it achieves the main goal, which is to output a randomly generated password of a certain length and content.

iv. Explains in detailed steps how the algorithm implemented in the identified procedure works. Your explanation must be detailed enough for someone else to recreate it.

Firstly, the procedure initializes the string "selectedChars". Next, it calls the function "isChecked" four times, once for each checkbox element. This will update "selectedChars" with all characters that are allowed to be in the generated password, based upon which types of characters the user has selected to be in the password. Next, it identifies where the output should be displayed and saves it as a constant "outputField". Then, it checks if "passwordLen", the desired password length inputted by the user, is invalid by using an if-statement and logical OR operators to see if it's empty, under less than or equal to 2, or greater than 99. If it's invalid, it displays an error message in the "outputField". If it's valid, then it initializes the string "pswd", then iterates the following steps over "i", initialized at 0, when "i" is less than the "passwordLen": it checks if the length of "selectedChars" is greater than 0, meaning the user has selected at least one type of character for the password to be. If it is over 0, then it generates a random number "c" between 0 and the length of "selectedChars" minus 1 (to account for the index starting at 0), concatenates "pswd" with the character at the index "c" in "selectedChars", and displays "pswd" in "outputField". Otherwise, if the length of "selectedChars" is less than or equal to 0, it displays an error message in "outputField".

3d.

Provides a written response that does all three of the following:

Approx. 200 words (for all subparts of 3d combined)

i. Describes two calls to the procedure identified in written response 3c. Each call must pass a different argument(s) that causes a different segment of code in the algorithm to execute.

First call:User inputs a password length of 101 and selects Numbers to be generated.

Second call:

User inputs a password length of 19 and selects all character types to be generated.

ii. Describes what condition(s) is being tested by each call to the procedure.

Condition(s) tested by first call:

The selective statement on line 269 that checks if "passwordLen" is empty, less than or equal to 2, or greater than 99, is being tested. The second condition in the statement is true.

Condition(s) tested by second call:

The same condition from the first call is being tested. However, this call does not make any of the conditions true, so it executes a different part of the code than the first call.

iii. Identifies the result of each call.

Result of the first call:

Error message: "Length must be between 3 and 99 characters".

Result of the second call:

Success. A randomly generated password that is 19 characters long and contains all selected character types.