Skip to content

Commit eda6245

Browse files
committedNov 18, 2018
✨ 🍱 🎉 Init add account payment order responsibility chain
1 parent 3662f8a commit eda6245

File tree

1 file changed

+35
-0
lines changed
  • src/behavioral/chain-of-responsibility/java/io/github/hooj0/chainofresponsibility/pay/support

1 file changed

+35
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.github.hooj0.chainofresponsibility.pay.support;
2+
3+
/**
4+
* account payment order responsibility chain
5+
* 账户支付顺序职责链条
6+
* @author hoojo
7+
* @createDate 2018年11月18日 上午10:07:39
8+
* @file PayChain.java
9+
* @package io.github.hooj0.chainofresponsibility.pay.support
10+
* @project design-patterns
11+
* @blog http://hoojo.cnblogs.com
12+
* @email hoojo_@126.com
13+
* @version 1.0
14+
*/
15+
public class PayChain {
16+
17+
private Account chain;
18+
19+
public PayChain() {
20+
chain = chainBuider();
21+
}
22+
23+
// 构建一个支付账户的链条
24+
private Account chainBuider() {
25+
Account account = new BankAccount(300);
26+
account = new BitcoinAccount(account, 400);
27+
account = new AlipayAccount(account, 200);
28+
29+
return account;
30+
}
31+
32+
public void pay(int amount) {
33+
chain.playHandled(amount);
34+
}
35+
}

0 commit comments

Comments
 (0)
Please sign in to comment.