-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
79 lines (65 loc) · 1.9 KB
/
User.java
File metadata and controls
79 lines (65 loc) · 1.9 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
69
70
71
72
73
74
75
76
77
78
79
package com.sherry;
import java.io.Serializable;
public class User extends Person implements Serializable {
String username;
String password;
/**
* Constructor of User
*
*/
public User(){}
/**
* User constructor give user info
*
* @param firstName First Name of the user
* @param lastName Last Name of the user
* @param username username of the user
* @param password password of the user
* @throws InValidNameException Exception for InValid Name
*/
public User(String firstName,String lastName,String username,String password) throws InValidNameException{
super(firstName,lastName);
this.setUsername(username);
this.setPassword(password);
}
/**
* Set Username
*
* @param username username of the user
* @throws InValidNameException Exception for InValid Name
*/
public void setUsername(String username) throws InValidNameException {
if(username.matches("^[\\d\\w]{4,}$")){
this.username = username;
}else {
throw new InValidNameException("Username must contain 4 character's or number's ");
}}
/**
* Set Password
*
* @param password password of user accounts
* @throws InValidNameException InValid Name Exception
*/
public void setPassword(String password) throws InValidNameException {
if(password.matches( "^.{6,}$")){
this.password = password;
}else{
throw new InValidNameException("Password must be atleast 6 character's long ");
}}
/**
* Get Password
*
* @return Password
*/
public String getPassword() {
return password;
}
/**
* Get username
*
* @return username
*/
public String getUsername() {
return username;
}
}