-
Notifications
You must be signed in to change notification settings - Fork 0
/
Account.java
67 lines (56 loc) · 1.7 KB
/
Account.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.*;
public class Account {
private int ID;
private String email;
private String password;
private int type;
Account(int aID, String aEmail, String aPassword, int aType){
ID = aID;
email = aEmail;
password = aPassword;
type = aType;
}
Account(int aID, String aEmail, int aType){
ID = aID;
email = aEmail;
password = generatePassword();
type = aType;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public static String generatePassword(){
String characters = "aA1bB2cC3dD4eE5fF6gG8hH9iI0jJkKlLmMnNoOpP&qQrRsStT_uUvV-wWxX+yYzZ";
String password = "";
for (int i = 0; i < 8; i++) {
password = password + " ";
}
Random random = new Random();
for (int i = 0; i < password.length(); i++) {
if (i == 0) {
password = String.valueOf(characters.charAt(random.nextInt(65))) + password.substring(1, password.length());
} else {
password = password.substring(0, i) + String.valueOf(characters.charAt(random.nextInt(65))) + password.substring(i + 1, password.length());
}
}
return password;
}
}