设计模式之桥接模式
来源:互联网 发布:科比詹姆斯知乎 编辑:程序博客网 时间:2024/06/06 04:55
package BridgeModel;public class BridgeModel1 {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubPerson man=new Man();Person lady=new Lady();Clothing jacket=new Jacket();Clothing trouser=new Trouser();jacket.personDressCloth(man);trouser.personDressCloth(man);jacket.personDressCloth(lady);trouser.personDressCloth(lady);}}abstract class Clothing{public abstract void personDressCloth(Person person);}class Jacket extends Clothing{@Overridepublic void personDressCloth(Person person) {// TODO Auto-generated method stubSystem.out.println(person.getType()+"穿夹克");}}class Trouser extends Clothing{@Overridepublic void personDressCloth(Person person) {// TODO Auto-generated method stubSystem.out.println(person.getType()+"穿裤子");}}abstract class Person{private Clothing clothing;private String type;public Clothing getClothing() {return clothing;}public void setClothing(Clothing clothing) {this.clothing = clothing;}public String getType() {return type;}public void setType(String type) {this.type = type;}public abstract void dress(); }class Man extends Person{public Man(){setType("男人");}@Overridepublic void dress() {// TODO Auto-generated method stubClothing clothing=getClothing();clothing.personDressCloth(this);}}class Lady extends Person{public Lady(){setType("女人");}@Overridepublic void dress() {// TODO Auto-generated method stubClothing clothing=getClothing();clothing.personDressCloth(this);}}
0 0
- 设计模式之桥接模式
- C# 设计模式 之 桥接模式
- c#设计模式之[桥接模式]
- 设计模式之桥接模式
- 设计模式之-Bridge-- 桥接模式
- 设计模式之桥接模式
- 设计模式之桥接模式
- 设计模式之Bridge(桥接模式)
- 设计模式之桥接模式
- 设计模式之Bridge(桥接模式)
- 设计模式之桥接模式BridgePattern
- C# 设计模式之桥接模式
- 设计模式之桥接模式
- 设计模式之桥接模式
- Java 设计模式 之 桥接模式
- Java 设计模式 之 桥接模式
- Java 设计模式 之 桥接模式
- 设计模式之桥接模式
- 1002. 写出这个数 (20)
- 使用POI替换word中的特定字符/文字)【改进】
- 按位与、或、异或等运算方法
- hibernate加载映射文件浅析
- getopt()
- 设计模式之桥接模式
- 数据结构-二叉树
- Codeforces Round #240 (Div. 1) 前3题 解题报告
- 设计模式之工厂模式
- xmind 安装及破解
- 称重传感器常用技术参数
- Android下PinnedHeaderListView使用
- BigDecimal的用法
- keystore 介绍