-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
47 lines (39 loc) · 1.18 KB
/
User.java
File metadata and controls
47 lines (39 loc) · 1.18 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
package onlinestore;
public class User {
private String name;
private String password;
public User(String name, String password) throws StringEmptyNullException {
setName(name);
setPassword(password);
}
public String getName() {
return name;
}
public void setName(String name) throws StringEmptyNullException {
if (name == null || name.isEmpty()) {
throw new StringEmptyNullException("name");
}
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) throws StringEmptyNullException {
if (password == null || password.isEmpty()) {
throw new StringEmptyNullException("Password");
}
this.password = password;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof User)) {
return false;
}
User user = (User) other;
return this.name.equals(user.getName()) && this.password.equals(user.getPassword());
}
@Override
public String toString() {
return "Username: " + name + "\n password: " + password;
}
}