forked from echoTheLiar/JavaCodeAcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
26 lines (20 loc) · 521 Bytes
/
Client.java
File metadata and controls
26 lines (20 loc) · 521 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
package designpattern.responsibilitychain;
/**
* 向链上的具体处理者对象提交请求
*
* @author liu yuning
*
*/
public class Client {
public static void main(String[] args) {
Handler handlerA = new ConcreteHandlerA();
Handler handlerB = new ConcreteHandlerB();
Handler handlerC = new ConcreteHandlerC();
handlerA.setSuccessor(handlerB);
handlerB.setSuccessor(handlerC);
int[] requests = { 2, 14, 5, 6, 8, 23, 12, 21 };
for (int i : requests) {
handlerA.handleRequest(i);
}
}
}