-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUserValidator.java
More file actions
33 lines (25 loc) · 839 Bytes
/
UserValidator.java
File metadata and controls
33 lines (25 loc) · 839 Bytes
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
import bankapplication.UserDetails;
public class UserValidator {
boolean flag = false;
public boolean isValidUserAge(UserDetails usterdetails, int age) {
flag=true; // Validating Age
while(flag) {
System.out.println("Enter your Age :");
if(age >=18)
{
usterdetails.setAge(age);
flag=false;
}
else if((age>=1) && (age<=17))
{
System.out.println("You're in under 18, so not eligible to create Bank Account. please Contact You're nearest branch.\n************ Thank you for using our service! Have a GREAT DAY **************");
}
else
{
flag=true;
//throw new InvalidAgeException("Please provide the correct age.\n");
}
}
return flag;
}
}