Skip to content

Commit 87b2f23

Browse files
Jason's computerJason's computer
authored andcommitted
optz adapter
1 parent 15ad44e commit 87b2f23

File tree

8 files changed

+102
-14
lines changed

8 files changed

+102
-14
lines changed

src/cn/ucaner/pattern/structure/adapter/adapterAbs/IOtherInfo.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@
2727
public interface IOtherInfo {
2828

2929
/**
30-
* @Description: 获取用户的User信息
31-
* @return HashMap<String,String>
30+
* @Description:获取用户的User信息
31+
* @return: HashMap<String,String>
32+
* @CreatTime: 2018年9月23日
3233
* @Autor: Jason - jasonandy@hotmail.com
3334
*/
3435
HashMap<String,String> getUserInfo();
3536

3637
/**
3738
* @Description: 获取的是用户的job信息
38-
* @return HashMap<String,String>
39+
* @return: HashMap<String,String>
40+
* @CreatTime: 2018年9月23日
3941
* @Autor: Jason - jasonandy@hotmail.com
4042
*/
4143
HashMap<String,String> getUserJobInfo();

src/cn/ucaner/pattern/structure/adapter/charge/ChargeTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ChargeTest {
2929
/**
3030
*
3131
* @Description: Just for test
32-
* @param args void
32+
* @param args
3333
* @Autor: Jason - jasonandy@hotmail.com
3434
*/
3535
public static void main(String[] args) {
@@ -38,6 +38,12 @@ public static void main(String[] args) {
3838

3939
ThreeInterface threeInterface = new Three2TwoAdapter(twoInterface);
4040

41+
ThreeInterface threeInterface2 = new HongKongCharge();
42+
43+
Three3TwoAdapter three3TwoAdapter = new Three3TwoAdapter(threeInterface2);
44+
45+
three3TwoAdapter.OfferPowerForTwo();
46+
4147
threeInterface.OfferPowerForThree();
4248
}
4349

src/cn/ucaner/pattern/structure/adapter/charge/ChinaCharge.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
*/
2626
public class ChinaCharge implements TwoInterface{
2727

28+
/**
29+
* OfferPowerForTwo 标准的两口插座
30+
*/
2831
@Override
2932
public void OfferPowerForTwo() {
30-
System.out.println("I'm China Charge. 220V.");
33+
System.out.println("I'm China Charge. 220V. - 中国的标准的220V 50HZ 电源.");
3134
}
32-
33-
3435

3536
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.structure.adapter.charge;
12+
13+
import cn.ucaner.pattern.structure.adapter.charge.inf.ThreeInterface;
14+
15+
/**
16+
* @Package:cn.ucaner.pattern.structure.adapter.charge
17+
* @ClassName:HongKongCharge
18+
* @Description: <p> </p>
19+
* @Author: - Jason
20+
* @CreatTime:2018年9月23日 - 上午11:00:08
21+
* @Modify By:
22+
* @ModifyTime: 2018年9月23日
23+
* @Modify marker:
24+
* @version V1.0
25+
*/
26+
public class HongKongCharge implements ThreeInterface{
27+
28+
/**
29+
* 大家好这里是标准的3口插头
30+
*/
31+
@Override
32+
public void OfferPowerForThree() {
33+
System.out.println("I'm Three Charge - HK Standard");
34+
}
35+
36+
}

src/cn/ucaner/pattern/structure/adapter/charge/Three2TwoAdapter.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,23 @@
2727
public class Three2TwoAdapter implements ThreeInterface{
2828

2929
/**
30-
* 2口充电头
30+
* 2口充电头 - 适配器
3131
*/
3232
TwoInterface twoInterface;
3333

34-
34+
/**
35+
* 3口 转两口的插座 - 适配
36+
* @param twoInterface
37+
*/
3538
public Three2TwoAdapter(TwoInterface twoInterface) {
3639
super();
3740
this.twoInterface = twoInterface;
3841
}
3942

4043

44+
/**
45+
* 三口的适配器 适用的是俩孔的插座
46+
*/
4147
@Override
4248
public void OfferPowerForThree() {
4349
twoInterface.OfferPowerForTwo();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* <html>
3+
* <body>
4+
* <P> Copyright 1994-2018 JasonInternational</p>
5+
* <p> All rights reserved.</p>
6+
* <p> Created on ${date} </p>
7+
* <p> Created by Jason - jasonandy@hotmail.com </p>
8+
* </body>
9+
* </html>
10+
*/
11+
package cn.ucaner.pattern.structure.adapter.charge;
12+
13+
import cn.ucaner.pattern.structure.adapter.charge.inf.ThreeInterface;
14+
import cn.ucaner.pattern.structure.adapter.charge.inf.TwoInterface;
15+
16+
public class Three3TwoAdapter implements TwoInterface{
17+
18+
ThreeInterface threeInterface;
19+
20+
/**
21+
* 2口 转3口的插座 - 适配
22+
* @param twoInterface
23+
*/
24+
public Three3TwoAdapter(ThreeInterface threeInterface) {
25+
super();
26+
this.threeInterface = threeInterface;
27+
}
28+
29+
30+
@Override
31+
public void OfferPowerForTwo() {
32+
threeInterface.OfferPowerForThree();
33+
}
34+
35+
}

src/cn/ucaner/pattern/structure/adapter/charge/inf/ThreeInterface.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
public interface ThreeInterface {
2626

2727
/**
28-
* @Description: 三个口的插头有 一 个 功能,能够为三个触角的插头提供电源
29-
* @Autor: jasonandy@hotmail.com
28+
* @Description:三个口的插头有 一 个 功能,能够为三个触角的插头提供电源
29+
* @CreatTime: 2018年9月23日
30+
* @Autor: Jason - jasonandy@hotmail.com
3031
*/
3132
public void OfferPowerForThree();
3233

src/cn/ucaner/pattern/structure/adapter/charge/inf/TwoInterface.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* <p> Created on 19941115</p>
77
* <p> Created by Jason</p>
88
* </body>
9+
* s
910
* </html>
1011
*/
1112
package cn.ucaner.pattern.structure.adapter.charge.inf;
@@ -25,9 +26,9 @@
2526
public interface TwoInterface {
2627

2728
/**
28-
*
29-
* @Description: 两口
30-
* @Autor: Jason - jasonandy@hotmail.com
29+
* @Description: 两口的插座
30+
* @CreatTime: 2018年9月23日
31+
* @Autor: Jason - jasonandy@hotmail.com
3132
*/
3233
public void OfferPowerForTwo();
3334

0 commit comments

Comments
 (0)