forked from mastifikator/FantasyJavaPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckLocation.java
More file actions
28 lines (23 loc) · 792 Bytes
/
Copy pathCheckLocation.java
File metadata and controls
28 lines (23 loc) · 792 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
package ChainOfResponsibility;
import java.util.ArrayList;
import java.util.List;
public class CheckLocation implements ICheck {
List<String> blockLocations = new ArrayList<>();
private User user;
public CheckLocation(User user) {
this.user = user;
blockLocations.add("USA");
blockLocations.add("Canada");
}
@Override
public User check(){
if(user == null) return null;
if(blockLocations.contains(user.getLocation())){
System.out.println("Пользователи из " + user.getLocation() + " заблокированы!");
return null;
}else{
System.out.println("Приветствуем гражданин " + user.getLocation());
return user;
}
}
}