Skip to content

Commit 41c6e7b

Browse files
committed
修改
1 parent 01f45e5 commit 41c6e7b

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

adapter/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,34 @@
1818

1919
## 模式分析
2020

21-
21+
> 假定现在有一个小汽车司机,他只会驾驶小型汽车,并不会驾驶公共汽车。
22+
>
23+
> 现在分别定义小汽车 ( Car ) 和公共汽车 ( Bus ) 两种接口
24+
25+
```
26+
public interface Car {
27+
void drive();
28+
}
29+
30+
public class Bus {
31+
private static final Logger LOGGER = LoggerFactory.getLogger(Bus.class);
32+
public void run() {
33+
LOGGER.info("公共汽车在行驶");
34+
}
35+
}
36+
```
37+
> 这个司机需要获得一辆小汽车才能进行驾驶活动
38+
39+
```
40+
public class Driver implements Car {
41+
private Car car;
42+
@Override
43+
public void drive() {
44+
car.drive();
45+
}
46+
public Driver(Car car) {
47+
this.car = car;
48+
}
49+
}
50+
```
2251
## 适用场景

0 commit comments

Comments
 (0)