Skip to content

Commit 04f4d1e

Browse files
author
hp
committed
[edit]桥接模式代码纠正错字,优化命名和排版
1 parent 6a03bc2 commit 04f4d1e

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/com/anxpp/designpattern/bridge/SimpleBridge.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,51 @@
22

33
//桥接模式
44
public class SimpleBridge {
5-
public static void main(String args[]) {
6-
new LenevoComputer(new Amd()).discribe();
7-
new HaseeComputer(new Intel()).discribe();
5+
public static void main(String[] args) {
6+
new LenovoComputer(new Amd()).describe();
7+
new HaseeComputer(new Intel()).describe();
88
}
99
}
1010

11-
//实现者
11+
// 实现者
1212
interface Cpu {
13-
String discribe();
13+
String describe();
1414
}
1515

16-
//具体实现者*2
16+
// 具体实现者*2
1717
class Amd implements Cpu {
18-
public String discribe() {
19-
return "just so so...";
18+
public String describe() {
19+
return "AMD YES!";
2020
}
2121
}
2222

2323
class Intel implements Cpu {
24-
public String discribe() {
25-
return "great !";
24+
public String describe() {
25+
return "INTEL LUNAR LAKE!";
2626
}
2727
}
2828

29-
//抽象
29+
// 抽象
3030
abstract class AbstractComputer {
3131
Cpu cpu;
3232

3333
public AbstractComputer(Cpu cpu) {
3434
this.cpu = cpu;
3535
}
3636

37-
public abstract void discribe();
37+
public abstract void describe();
3838

3939
}
4040

41-
//细化抽象*2
42-
class LenevoComputer extends AbstractComputer {
43-
public LenevoComputer(Cpu cpu) {
41+
// 细化抽象*2
42+
class LenovoComputer extends AbstractComputer {
43+
public LenovoComputer(Cpu cpu) {
4444
super(cpu);
4545
}
4646

4747
@Override
48-
public void discribe() {
49-
System.out.println("联想笔记本cpu:" + super.cpu.discribe());
48+
public void describe() {
49+
System.out.println("联想笔记本cpu:" + super.cpu.describe());
5050
}
5151
}
5252

@@ -56,7 +56,7 @@ public HaseeComputer(Cpu cpu) {
5656
}
5757

5858
@Override
59-
public void discribe() {
60-
System.out.println("神舟笔记本cpu:" + super.cpu.discribe());
59+
public void describe() {
60+
System.out.println("神舟笔记本cpu:" + super.cpu.describe());
6161
}
6262
}

src/com/anxpp/designpattern/bridge/TestUse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.anxpp.designpattern.bridge;
22

33
public class TestUse {
4-
public static void main(String args[]) {
4+
public static void main(String[] args) {
55
Object data = "数据";
66
ISaveData saveDataDb = new SaveToDB();
77
ISaveData saveDataFile = new SaveToFile();

0 commit comments

Comments
 (0)