-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.java
172 lines (140 loc) · 4 KB
/
User.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package org.haderlie.claire.dundrag;
import java.util.ArrayList;
/**
* A User class for holding the user information
*
* This class is used to store the user's data from the database
* and interact with its list of characters.
*
* @author Niclairex
* @version 3.14159
*/
public class User {
//List of the characters that the user has
ArrayList<Character> characters;
//The username
String username;
//User's password
String password;
//A hashed version of the users' password
String passHash;
//Salt for the hashing
String salt;
//The user's full name
String firstName;
String lastName;
//A boolean determining if the user is signed up for a table_draft or not
Boolean isSignedUp;
User() {
username = "";
password = "";
firstName = "";
lastName = "";
}
User(String usrname, String pswd) {
username = usrname;
password = pswd;
}
User(String newUserName, String pswd, String newFirst, String newLast) {
username = newUserName;
password = pswd;
firstName = newFirst;
lastName = newLast;
}
public String getUsername() {
return username;
}
public void setUsername(String newUsername) {
username = newUsername;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String newName) {
firstName = newName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String newName) {
lastName = newName;
}
public String getHashedPassword() {
return passHash;
}
public void setHashedPassword(String hashString){
passHash = hashString;
}
public void setSalt(String saltString){
salt = saltString;
}
public String getSalt(){
return salt;
}
public void setPassword(String newPswd) {
password = newPswd;
}
public String getPassword() {
return password;
}
public void setPassHash(String hash) {
passHash = hash;
}
/**
* Check if the user is already signed up for a table_draft or not
*
* @return isSignedUp A boolean to return {@code true} or {@code false} whether
* the user is signed up.
*/
public Boolean getIsSignedUp() {
return isSignedUp;
}
/**
* Change if the user is signed up for a table_draft or not
*
* @param signedUp The new {@code true} or {@code false} signifying that the
* user is signed up.
*/
public void setIsSignedUp(boolean signedUp) {
isSignedUp = signedUp;
}
/**
*
* @return characters Send back a copy of the list of {@code characters}
*/
public ArrayList<Character> getCharacters() {
return characters;
}
/**
* Remove a character from a the list
*
* @param index The index of the character that is to be removed from
* the list.
*/
public void removeCharacter(int index) {
characters.remove(index);
}
/**
* Add a new character into the characters list
*
* @param newChar The new character that is to be put into the User's
* characters list
*/
public void addCharacter(Character newChar) {
characters.add(newChar);
}
/**
* Edit a character in the {@code characters} ArrayList
*
* <p>
* It is a "pseudo" edit. The {@code Character} itself is not changed, but instead
* the {@code Character} at the given index is replaced with an edited version of itself.
* </p>
* @param index The index of the {@code Character} that is to be replaced.
* @param editedCharacter A new {@code Character} that was copied from a {@code Character}
* and changed.
*/
public void editCharacter(int index, Character editedCharacter) {
characters.add(index, editedCharacter);
}
}