-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.java
164 lines (146 loc) · 3.34 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
import java.util.UUID;
public class User {
private UUID id;
private UserType type;
private String firstName;
private String lastName;
private String email;
private String password;
/**
* Constructor for User to be created by an admin
* @return
*/
public User(String firstName, String lastName, String email, String password, UserType type) {
this.id = UUID.randomUUID();
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.password = password;
this.type = type;
}
/**
* Constructor for User importing data from the database
* @return
*/
public User(UUID id, String firstName, String lastName, String email, String password) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.password = password;
}
//added
public User(String firstName, String lastName, String email, String password) {
this(UUID.randomUUID(), firstName, lastName, email, password);
}
/**
* Gets the ID of the user
* @return
*/
public UUID getID() {
return id;
}
/**
* Sets the ID of the user
* @return
*/
public void setID(UUID id) {
this.id = id;
}
/**
* Sets the type of user
* @return
*/
public void setUserType(UserType type) {
this.type = type;
}
/**
* Returns the type of user
* @return
*/
public UserType getUserType() {
return type;
}
/**
* Gets the first name of the user
* @return
*/
public String getFirstName() {
return firstName;
}
/**
* Sets the first name of the user
* @param firstName
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* Gets the last name of the user
* @return
*/
public String getLastName() {
return lastName;
}
/**
* Sets the last name of the user
* @param lastName
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* Gets the email of the user
* @return
*/
public String getEmail() {
return email;
}
/**
* Sets the email of the user
* @param email
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Gets the password of the user
* @return
*/
public String getPassword() {
return password;
}
/**
* Sets the password of the user
* @param password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the string representation of the user
* @return
*/
public String toString() {
return "Name: " + this.firstName + " " + this.lastName +
"\tEmail: " + this.email;
}
/**
* Returns true if the user is a student
* @return
*/
public boolean isStudent() {
if(this.type == UserType.STUDENT) {
return true;
}
return false;
}
/**
* Compare 2 User object
* @param User
* @return boolean
*/
public boolean equals(User user) {
return user.getID().equals(this.id);
}
}