Slide 15
Slide 15 text
jgs
460 00010010
Chain of Responsibility
public class Client {
public static void main(String[] args) {
// Setup Chain of Responsibility
ConcreteHandler2 h1 = new ConcreteHandler2();
ConcreteHandler2 h2 = new ConcreteHandler2();
ConcreteHandler1 h3 = new ConcreteHandler1();
h1.setSuccessor(h2);
h2.setSuccessor(h3);
// Generate and process request
int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 };
for (int i = 0; i < requests.length; i++) {
h1.HandleRequest(requests[i]);
}
}
}