【发布时间】:2016-05-22 05:32:53
【问题描述】:
这是我有一个法术类的情况
public abstract class Spell
{
public abstract void Castspell ();
}
public class Heal:Spell
{
Dictionary<string, int> heals = new Dictionary<string,int> ();
public Heal()
{
heals.Add ("less heal", 1);
heals.Add ("medium heal", 2);
heals.Add (" large heal", 3);
}
public override void Castspell()
{
}
}
忽略 Castspell(),还有另一个类叫做 student
public class student
{
public enum spells
{
lessheal,
mediumheal,
highheal
}
List<Spell> _skillist = new List<Spell>();
public student()
{
//...
}
public void learnskills()
{
_skillist.Clear ();
Spell newspell = new Spell ();
_skillist.Add (newspell);
}
我在这里要做的是我想学习技能方法,每次我调用它都会随机添加一个治疗法术到_skillist。(它可以是更少,中等或高)。我怎么能做到呢?请给我一些建议。谢谢
【问题讨论】:
-
您在这个问题中的代码无法编译。您应该始终确保您的代码是minimal reproducible example。