-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
68 lines (63 loc) · 1.6 KB
/
Copy pathUser.java
File metadata and controls
68 lines (63 loc) · 1.6 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
66
67
68
package UserPack;
import java.io.Serializable;
/**
* Abstract class representing a user.
* are inherited by such classes as {@link Voter} and {@link Host}
* Serialization is used {@link Serializable}
*/
public abstract class User implements Serializable {
protected String username;
protected String password;
/**
* Abstract method to get the role of the user.
*
* @return The role of the user.
*/
public abstract String getRol();
/**
* Sets the username for the user.
*
* @param username The username to set.
*/
public void setUsername(String username){
this.username=username;
}
/**
* Gets the username of the user.
*
* @return The username of the user.
*/
public String getUsername(){
return this.username;
}
/**
* Sets the password for the user.
*
* @param password The password to set.
*/
public void setPassword(String password){
this.password=password;
}
/**
* Gets the password of the user.
*
* @return The password of the user.
*/
public String getPassword(){
return this.password;
}
/**
* Method to login a user.
*
* @param username The username to check.
* @param password The password to check.
* @return True if the username and password match, otherwise false.
*/
public boolean login(String username,String password){
if (this.username.equals(username) && this.password.equals(password)){
return true;
}else{
return false;
}
}
}