-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.java
53 lines (45 loc) · 1.7 KB
/
Client.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
package implementation.chainOfResponsibility;
import java.time.LocalDate;
public class Client {
public static void main(String[] args) {
LeaveApplication application1 = LeaveApplication.getBuilder()
.withType(LeaveApplication.Type.Sick)
.from(LocalDate.now())
.to(LocalDate.now().plusDays(2))
.build();
LeaveApprover approver = createChain();
System.out.println("++++++++++++++++++++++++++++++++++++++");
approver.processLeaveApplication(application1);
System.out.println(application1);
LeaveApplication application2 = LeaveApplication.getBuilder()
.withType(LeaveApplication.Type.Sick)
.from(LocalDate.now())
.to(LocalDate.now().plusDays(5))
.build();
System.out.println("++++++++++++++++++++++++++++++++++++++");
approver.processLeaveApplication(application2);
System.out.println(application2);
LeaveApplication application3 = LeaveApplication.getBuilder()
.withType(LeaveApplication.Type.PTO)
.from(LocalDate.now())
.to(LocalDate.now().plusDays(4))
.build();
System.out.println("++++++++++++++++++++++++++++++++++++++");
approver.processLeaveApplication(application3);
System.out.println(application3);
LeaveApplication application4 = LeaveApplication.getBuilder()
.withType(LeaveApplication.Type.PTO)
.from(LocalDate.now())
.to(LocalDate.now().plusDays(10))
.build();
System.out.println("++++++++++++++++++++++++++++++++++++++");
approver.processLeaveApplication(application4);
System.out.println(application4);
}
private static LeaveApprover createChain() {
Director director = new Director(null);
Manager manager = new Manager(director);
ProjectLead lead = new ProjectLead(manager);
return lead;
}
}