Files
java-design-patterns/chain/src/main/java/com/iluwatar/App.java
T
2014-08-31 10:52:37 +03:00

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"));
}
}