我的問題在於繼承可播放角色的屬性。我有一個名爲Being的抽象類,它指出所有的繼承類都需要包含力量,敏捷等屬性。玩家需要選擇一個種族,例如,獸人將力量從0提升到10,然後玩家需要選擇一個類,比如蠻力,這樣可以爲英雄的力量增加7點。據我看,它會繼續我的英雄類繼承2抽象類?這是我的獸人類的摘錄:如何解決在我的遊戲中繼承2個抽象類的問題?
public abstract class Orc:Being
{
private int _strength = 10;
//Another question, is it okay to declare an abstract property in my base abstract
//class to force the inheriting class Orc to override the property? I wanted to
//find a way to force subclasses to have strength attributes
public override int Strength
{
get {return _strength;}
set {_strength = value;}
}
}
裝飾模式http://www.dofactory.com/Patterns/PatternDecorator.aspx#_self2 – daryal