Add files via upload

This commit is contained in:
Aesthetiful authored and GitHub committed 2024-06-13 08:40:42 -07:00
1 parent 49c6374d74
commit 59d556f1b4
6 files changed
+313

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import java.util.Random;
public class PasswordGenerator {
private String prefix;
private int generatedCount;
public PasswordGenerator(int num, String prefix) {
this.prefix = prefix;
this.generatedCount = num;
}
public PasswordGenerator(int num) {
this.prefix = "A";
this.generatedCount = num;
}
public String pwGen() {
Random random = new Random();
String password = "";
password += prefix + ".";
for (int i = 0; i < 4; i++) {
password += (int) (Math.random() * 10);
}
generatedCount++;
return password;
}
public int pwCount() {
return generatedCount;
}
public static void main(String[] args) {
PasswordGenerator pw1 = new PasswordGenerator(4, "chs");
System.out.println(pw1.pwCount());
System.out.println(pw1.pwGen());
}
}