-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathUser.js
66 lines (48 loc) · 1009 Bytes
/
User.js
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
var USER_ID = 0
class User {
#id
#name
#email
#phone
constructor(){
this.#id = USER_ID++
}
get Name() {
return this.#name
}
get Email() {
return this.#email
}
get Phone() {
return this.#phone
}
get ID() {
return this.#id
}
set Name(name) {
if(name === "" || name === undefined) {
throw "name can't be empty"
}
this.#name = name
}
set Email(email) {
if(email === "" || email === undefined) {
throw "name can't be empty"
}
this.#email = email
}
set Phone(phone) {
if(phone === "" || phone === undefined) {
throw "name can't be empty"
}
this.#phone = phone
}
static createUser(name, email, phone) {
var user = new User()
user.Name = name
user.Email = email
user.Phone = phone
return user
}
}
module.exports.User = User