22 lines
666 B
Java
22 lines
666 B
Java
package learn.simple_responsibility_chain;
|
|
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
Handler firstHandler = new ConcreteHandler1();
|
|
Handler secondHandler = new ConcreteHandler2();
|
|
Handler thirdHandler = new ConcreteHandler3();
|
|
|
|
firstHandler.setSuccessor(secondHandler);
|
|
secondHandler.setSuccessor(thirdHandler);
|
|
|
|
Request request1 = new Request("dog");
|
|
firstHandler.handleRequest(request1);
|
|
|
|
Request request2 = new Request("3");
|
|
firstHandler.handleRequest(request2);
|
|
|
|
Request request3 = new Request("house");
|
|
firstHandler.handleRequest(request3);
|
|
}
|
|
}
|