-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAccount.java
More file actions
79 lines (67 loc) · 2.09 KB
/
Account.java
File metadata and controls
79 lines (67 loc) · 2.09 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package Test;
/**
*
* @author asraf
*/
public class Account {
private String userID;
private String userName;
private String password;
private static int ID=0;
public Account(){
userID = null;
userName = null;
password = null;
}
public Account(String userName, String password){
this.userID = generateID();
this.userName = userName;
this.password = password;
}
public Account(String userID, String userName, String password) {
this.userID = userID;
this.userName = userName;
this.password = password;
}
public String getUserID() {
return userID;
}
public String getUserName() {
return userName;
}
public String getPassword() {
return password;
}
/**
* Creates a unique Confession Post ID.
* This method generate an ID by checking the data class.
* If a post ID already taken, it will increase counter by 1 until
* it found an available post ID.
* @return the generated post ID of the new post
*/
public String generateID(){
userID = "UID0"+ID;
ID++;
if(!checkAvailableID(userID)){
generateID();
}
return userID;
}
/**
* Returns true if newly generated post ID is not found in the data class.
* @param postID newly generated post ID from generateID()
* @return true, if newly generated post ID is not found in the data class
*/
public Boolean checkAvailableID(String userID){
RegisterAccount data = new RegisterAccount();
return data.searchID(userID)==null;
}
@Override
public String toString() {
return "userID=" + userID + "\nuserName="+userName + "\npassword=" + password;
}
}