1 Responsibility Chain Mode
1.1 Job Title
in combat, generally according to the size and importance of the scale of war, by different ranks of the officers (officer)to give a tactical order, and the intelligence officer submits it to his superiors.(including information such as number of enemies), the command needs to be approved by the superior, if the direct superior does not have the power to give orders, then passed to his superiors, until someone can decide so far. The current responsibility chain model to simulate the process, customer-class analog intelligence personnel, first to the lowest level of the monitor (Bangzhang), submit a task book(Mission), that is, the military , if beyond the scope of the monitor's jurisdiction, then passed to the platoon Sergeant (Paizhang), if the platoon leader cannot handle it, it is passed to the battalion commander (Yingzhang) , if the battalion commander is unable to deal with it, a meeting will be held, and the authority of the officers is set:
1>. The number of the enemy is small <10, the monitor issued a combat order
2>. 10=< enemy Number <50, platoon commander orders
3>. 50=< enemy Number <200, battalion commander issued combat orders
4>. 200=< the number of enemies, need to meet to discuss
(1) Drawing the view of responsibility chain pattern structure;
(2) Please draw the instance class diagram and code implementation.
2 Command Mode
2.1 Job Title
A software company to develop a Windows platform-based bulletin board system, which provides a main menu (menu), in the main menu contains a number of items (MenuItem), you can use the menu class AddMenuItem () method to add menus, The Main method on the menu is click (), each menu item contains an abstract command class, the specific command class contains Opencommand (Open command), CreateCommand (Create command) and Editecommand (Edit command), etc. The command class has a built-in Excute () method that invokes the open (), create (), Edite (), and other methods of the bulletin board System Interface Class (Boardscrean), and now uses the command mode to design the system.
( 1) drawing the command pattern structure view
( 2 ) give the instance class diagram and implement the code.
This article is from the "10924720" blog, please be sure to keep this source http://10934720.blog.51cto.com/10924720/1886643
Behavioral pattern Java