编辑:我可以使用 Actionscript 3.0 和/或 Java
我对装饰器类有点问题。我希望能够装饰抽象类的子类的子类。
澄清; 我有abstract weapon class
,abstract sword class
扩展。然后,最后 aconcrete long sword class
扩展它。我希望能够装饰long sword class
.
Weapon <-------------Enchant "Decorator
/\ / \
/ \ "+3 damage"|"Paralyze"
/ \ V
"Abstract Components": Sword | Axe "Concrete Decorators"
/ \ / \
/ \ / \
"Concrete Components": LongSword|Short RedAxe| WarAxe "Apply Decorators Here"
目前我读过的所有关于设计模式的书都涉及“一层”装饰,例如:
Weapon <-------------Enchant "Decorator
/\ / \
/ \ "+3 damage"|"Paralyze"
/ \ V
"Concrete components already": Sword | Axe "Concrete Decorators"