-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckpointController.java
59 lines (47 loc) · 1.6 KB
/
CheckpointController.java
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
package com.company;
public class CheckpointController {
private final Database registeredPlates;
private final Database blacklist;
private final Database addresses;
public Database getRegisteredPlates() {
return registeredPlates;
}
public Database getBlacklist() {
return blacklist;
}
public Database getAddresses() {
return addresses;
}
public CheckpointController() {
this.registeredPlates = new Database("plates.db");
this.blacklist = new Database("blacklist.db");
this.addresses = new Database("addresses.db");
}
public void requestAccess(String plate, String address){
if (blacklist.getContent().contains(plate)){
System.out.println("Access denied Plate in on the blacklist");
return;
}
if (registeredPlates.getContent().contains(plate)){
System.out.println("Calling "+ address);
return;
}
if (addresses.getContent().contains(address)){
registeredPlates.getContent().add(plate);
System.out.println("Calling "+ address+"Access Granted");
} else {
System.out.println("Address not found, blacklisting plate");
blacklistPlate(plate);
}
}
public void registerAddress(String address){
addresses.content.add(address);
System.out.println("Address registere");
}
public void removeAddress(String address){
addresses.content.remove(address);
}
public void blacklistPlate(String plate){
blacklist.content.add(plate);
}
}