22
33//桥接模式
44public 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+ // 实现者
1212interface Cpu {
13- String discribe ();
13+ String describe ();
1414}
1515
16- //具体实现者*2
16+ // 具体实现者*2
1717class Amd implements Cpu {
18- public String discribe () {
19- return "just so so... " ;
18+ public String describe () {
19+ return "AMD YES! " ;
2020 }
2121}
2222
2323class Intel implements Cpu {
24- public String discribe () {
25- return "great !" ;
24+ public String describe () {
25+ return "INTEL LUNAR LAKE !" ;
2626 }
2727}
2828
29- //抽象
29+ // 抽象
3030abstract 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}
0 commit comments