Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions Password Generator/src/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,30 @@ private void requestPassword() {
}

} while (correctParams);

int length;

do {
System.out.println("Great! Now enter the length of the password (must be a positive integer):");
//Directs user to enter a valid integer
while (!keyboard.hasNextInt()) {
System.out.println("Invalid input. Please enter a valid integer length:");
keyboard.next();
}
length = keyboard.nextInt();

//Ensures the user enter an integer value that is greater than zero for a valid password to be generated
if (length <= 0) {
System.out.println("Password length should be greater than zero.");
}
} while (length <= 0);

System.out.println("Great! Now enter the length of the password");
int length = keyboard.nextInt();

final Generator generator = new Generator(IncludeUpper, IncludeLower, IncludeNum, IncludeSym);
final Password password = generator.GeneratePassword(length);

final Generator generator = new Generator(IncludeUpper, IncludeLower, IncludeNum, IncludeSym);
final Password password = generator.GeneratePassword(length);
System.err.println("Your generated password -> " + password);

System.err.println("Your generated password -> " + password);
}

private boolean isInclude(String Input) {
Expand Down