Archived
Add files via upload
This commit is contained in:
1 parent
49c6374d74
commit
59d556f1b4
6 files changed
+313
No files matched your search
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user