-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
65 lines (55 loc) · 1.58 KB
/
Copy pathUser.java
File metadata and controls
65 lines (55 loc) · 1.58 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
package com.cs2212;
/**
* This class represents a user object with a username and password.
*/
public class User {
private String username;
private String password;
/**
* Constructs a new User object with the specified username and password.
* @param username the username of the user
* @param password the password of the user
*/
public User (String username, String password) {
this.username = username;
this.password = password;
}
/**
* Returns the username of the user.
* @return the username of the user
*/
public String getUsername() {
return this.username;
}
/**
* Returns the password of the user.
* @return the password of the user
*/
public String getPassword() {
return this.password;
}
/**
* Sets the username of the user.
* @param newUsername the new username to set
* @return true if the username was successfully set, false otherwise
*/
public boolean setUsername (String newUsername) {
// Check if username exists
boolean usernameExists = false;
if (usernameExists) {
return false;
} else {
this.username = newUsername;
return true;
}
}
/**
* Sets the password of the user.
* @param newPassword the new password to set
* @return true if the password was successfully set
*/
public boolean setPassword (String newPassword) {
this.password = newPassword;
return true;
}
}