标签:分享 private java http 特性 扩展 子类 发展 生成
public interface SwordMan { void attackMagic(); }
public class Yanguo implements SwordMan { @Override public void attackMagic() { System.out.println("杨过使用全真剑法"); } }
public abstract class Master implements SwordMan { SwordMan swordMan; @Override public void attackMagic() { swordMan.attackMagic(); } public Master(SwordMan swordMan) { this.swordMan = swordMan; } }
public class HongQiGong extends Master { public HongQiGong(SwordMan swordMan) { super(swordMan); } @Override public void attackMagic() { super.attackMagic(); techAttackMagic(); } private void techAttackMagic() { System.out.println("洪七公教授打狗棒法"); System.out.println("杨过学会打狗棒法"); } }
public class ClientDecorator { public static void main(String[] rags){ SwordMan swordMan = new Yanguo(); HongQiGong hongQiGong = new HongQiGong(swordMan); hongQiGong.attackMagic(); } }
标签:分享 private java http 特性 扩展 子类 发展 生成
原文地址:https://www.cnblogs.com/endian11/p/9144136.html