-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInternetAccess.java
More file actions
53 lines (41 loc) · 1.26 KB
/
InternetAccess.java
File metadata and controls
53 lines (41 loc) · 1.26 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
package Solutions;
interface OfficeInternetAccess {
public void grantInternetAccess();
}
class RealInternetAccess implements OfficeInternetAccess {
private String employeeName;
public RealInternetAccess(String empName) {
this.employeeName = empName;
}
@Override
public void grantInternetAccess() {
System.out.println("Internet Access granted for employee: " + employeeName);
}
}
class ProxyInternetAccess implements OfficeInternetAccess {
private String employeeName;
private RealInternetAccess realaccess;
public ProxyInternetAccess(String employeeName) {
this.employeeName = employeeName;
}
@Override
public void grantInternetAccess() {
if (getRole(employeeName) > 4) {
realaccess = new RealInternetAccess(employeeName);
realaccess.grantInternetAccess();
} else {
System.out.println("No Internet access granted. Your job level is below 5");
}
}
public int getRole(String emplName) {
// Check role from the database based on Name and designation
// return job level or job designation.
return 9;
}
}
public class InternetAccess {
public static void main(String[] args) {
OfficeInternetAccess access = new ProxyInternetAccess("Ashwani Rajput");
access.grantInternetAccess();
}
}