Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 15ad44e

Browse files
🎉 opts java pattern command
1 parent 9593851 commit 15ad44e

File tree

7 files changed

+134
-23
lines changed

7 files changed

+134
-23
lines changed

‎src/cn/ucaner/pattern/action/command/CommandMain.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@
2525
*/
2626
public class CommandMain {
2727

28+
/**
29+
* @Description: Just for test
30+
* @Autor: Jason- jasonandy@hotmail.com
31+
*/
2832
public static void main(String[] args) {
2933
Invoker invoker=new Invoker();
3034
invoker.setCommand(new AddPageCommand());
31-
invoker.Action();
35+
invoker.Call();
3236
}
3337

3438
}

‎src/cn/ucaner/pattern/action/command/Invoker.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ public void setCommand(Command command) {
3131
this.command = command;
3232
}
3333

34-
public void setCommand(String str) {
35-
36-
}
37-
38-
public void Action() {
34+
public void Call() {
3935
this.command.execute();
4036
}
4137
}

‎src/cn/ucaner/pattern/action/command/Product.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public void doDel() {
4545
public void plan() {
4646
System.out.println("产品变更完毕");
4747
}
48+
49+
public void acceptance() {
50+
System.out.println("产品经理验收");
51+
}
4852
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* <html>
3+
* <body>
4+
* <P> Copyright 1994 JsonInternational</p>
5+
* <p> All rights reserved.</p>
6+
* <p> Created on 19941115</p>
7+
* <p> Created by Jason</p>
8+
* </body>
9+
* </html>
10+
*/
11+
package cn.ucaner.pattern.action.command;
12+
13+
import cn.ucaner.pattern.action.command.absCommand.Group;
14+
15+
/**
16+
* @Package:cn.ucaner.pattern.action.command
17+
* @ClassName:Projecter
18+
* @Description: <p> 项目经理</p>
19+
* @Author: - Jason
20+
* @CreatTime:2018年6月20日 上午8:38:44
21+
* @Modify By:
22+
* @ModifyTime: 2018年6月20日
23+
* @Modify marker:
24+
* @version V1.0
25+
*/
26+
public class Projecter extends Group{
27+
28+
@Override
29+
public void getCommand() {
30+
System.out.println("项目经理讨论项目方案");
31+
}
32+
33+
@Override
34+
public void doAdd() {
35+
System.out.println("批准项目");
36+
}
37+
38+
@Override
39+
public void doDel() {
40+
System.out.println("重审项目");
41+
}
42+
43+
@Override
44+
public void plan() {
45+
System.out.println("实施项目落地");
46+
}
47+
48+
public void acceptance() {
49+
System.out.println("项目验收");
50+
}
51+
52+
}

‎src/cn/ucaner/pattern/action/command/absCommand/Command.java‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
*/
1111
package cn.ucaner.pattern.action.command.absCommand;
1212

13+
import java.util.List;
14+
1315
import cn.ucaner.pattern.action.command.Code;
1416
import cn.ucaner.pattern.action.command.Product;
17+
import cn.ucaner.pattern.action.command.Projecter;
1518
import cn.ucaner.pattern.action.command.UI;
1619

1720
/**
@@ -27,11 +30,41 @@
2730
*/
2831
public abstract class Command {
2932

30-
protected Product product=new Product();
33+
/**
34+
* 项目经理
35+
*/
36+
protected Projecter pm = new Projecter();
37+
38+
/**
39+
* 产品经理
40+
*/
41+
protected Product product = new Product();
3142

32-
protected UI ui=new UI();
43+
/**
44+
* UI
45+
*/
46+
protected UI ui = new UI();
3347

48+
/**
49+
* 码农实现
50+
*/
3451
protected Code code =new Code();
35-
//执行
52+
53+
54+
/* private List<Group> gps;
55+
56+
public List<Group> getGps() {
57+
return gps;
58+
}
59+
60+
public void setGps(List<Group> gps) {
61+
this.gps = gps;
62+
}*/
63+
64+
65+
/**
66+
* @Description: execute
67+
* @Autor: Jason - jasonandy@hotmail.com
68+
*/
3669
public abstract void execute();
3770
}

‎src/cn/ucaner/pattern/action/command/absCommand/Group.java‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,29 @@
2222
* @version V1.0
2323
*/
2424
public abstract class Group {
25-
//得到命令
26-
public abstract void getCommand();
27-
//新增一个功能
25+
26+
/**
27+
* @Description: 得到命令
28+
* @Autor: Jason - jasonandy@hotmail.com
29+
*/
30+
public abstract void getCommand();
31+
32+
/**
33+
* @Description: 新增一个功能
34+
* @Autor: Jason - jasonandy@hotmail.com
35+
*/
2836
public abstract void doAdd();
29-
//减去一个功能
37+
38+
/**
39+
* @Description: 减去一个功能
40+
* @Autor: Jason - jasonandy@hotmail.com
41+
*/
3042
public abstract void doDel();
31-
//开始实施
43+
44+
/**
45+
* @Description: 开始实施
46+
* @Autor: Jason - jasonandy@hotmail.com
47+
*/
3248
public abstract void plan();
3349

3450
}

‎src/cn/ucaner/pattern/action/command/command/AddPageCommand.java‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ public class AddPageCommand extends Command {
2727

2828
@Override
2929
public void execute() {
30-
product.getCommand();
31-
ui.getCommand();
32-
code.getCommand();
33-
product.doAdd();
34-
product.plan();
35-
ui.doAdd();
36-
ui.plan();
37-
code.doAdd();
38-
code.plan();
30+
//项目经理
31+
super.pm.getCommand();
32+
product.getCommand();//产品经理
33+
ui.getCommand();//ui
34+
code.getCommand();//码农
35+
pm.doAdd();
36+
product.doAdd();//添加
37+
pm.plan();
38+
product.plan();//执行
39+
ui.doAdd();//添加
40+
ui.plan();//执行
41+
code.doAdd();//添加
42+
code.plan();//执行
43+
product.acceptance();
44+
pm.acceptance();
3945
}
4046
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /