码迷,mamicode.com
首页 > 其他好文 > 详细

design_model(7)bridge

时间:2018-09-01 14:35:22      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:inter   nts   pre   div   compute   put   rgs   str   sharp   

1.桥接模式:可以使得两个不同接口的实现的不同组合

2.实例

public interface Brand {

}

public class Huasuo implements  Brand{
	
}

public interface  Computer {

}

public class Desktop  implements Computer{
   private Brand  brand;

  public Desktop(Brand brand) {
	super();
	this.brand = brand;
  }
  
}

public class Client {
   public static void main(String[] args) {
	 Desktop desktop = new Desktop(new Huasuo());
  }
}

 

design_model(7)bridge

标签:inter   nts   pre   div   compute   put   rgs   str   sharp   

原文地址:https://www.cnblogs.com/gg128/p/9570160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!