package DecoratorModel;
/**
* 2017-10-9 10:39:09
* 装饰器设计模式
* Person 类 ConcreteComponent
* @author 我不是张英俊
*
*/
public class Person {
public Person(){}
private String name;
public Person(String name){
this.name=name;
}
public void Show(){
System.out.println("装扮的"+name);
}
}
package DecoratorModel;
/**
*服饰类(Decorator)
* @author 我不是张英俊
*
*/
public class Finery extends Person{
protected Person component;
//打扮
public void Decorate(Person component){
this.component=component;
}
public void Show(){
if(component!=null){
component.Show();
}
}
}
public class Tshirts extends Finery {
public void Show(){
System.out.println("大T恤");
super.Show();
}
}
public class BigTrouser extends Finery {
public void Show(){
System.out.println("垮裤");
super.Show();
}
}
public class Sneakers extends Finery {
public void Show(){
System.out.println("破球鞋");
super.Show();
}
}
public class Suit extends Finery {
public void Show(){
System.out.println("西装");
super.Show();
}
}
public class Tie extends Finery {
public void Show(){
System.out.println("领带");
super.Show();
}
}
public class LeatherShoes extends Finery {
public void Show(){
System.out.println("皮鞋");
super.Show();
}
}
public class test {
public static void main(String[] args) {
Person xc=new Person("旺财");
Sneakers pqx=new Sneakers();
BigTrouser kk=new BigTrouser();
Tshirts dtx=new Tshirts();
pqx.Decorate(xc);
kk.Decorate(pqx);
dtx.Decorate(kk);
dtx.Show();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有