mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 20:59:07 +00:00
23 lines
721 B
Java
23 lines
721 B
Java
package com.iluwatar;
|
|
|
|
/**
|
|
*
|
|
* Chain of Responsibility organizes request handlers (RequestHandler) into
|
|
* a chain where each handler has a chance to act on the request on its
|
|
* turn. In this example the king (OrcKing) makes requests and the military
|
|
* orcs (OrcCommander, OrcOfficer, OrcSoldier) form the handler chain.
|
|
*
|
|
*/
|
|
public class App
|
|
{
|
|
public static void main( String[] args )
|
|
{
|
|
|
|
OrcKing king = new OrcKing();
|
|
king.makeRequest(new Request(RequestType.DEFEND_CASTLE, "defend castle"));
|
|
king.makeRequest(new Request(RequestType.TORTURE_PRISONER, "torture prisoner"));
|
|
king.makeRequest(new Request(RequestType.COLLECT_TAX, "collect tax"));
|
|
|
|
}
|
|
}
|