samedi 21 mai 2016

random value assign with the class combination

Here is the case I have got a spell class

    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()
    {
    }


}

ignore the Castspell(), and there is another class called 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);

    }

what I am trying to do here is I wanna make learn skill method, each time I Call It will randomly add a heal spell into the _skillist.(it could be less, medium or high). how could I achieve it? please give me some advices about it.thanks




Aucun commentaire:

Enregistrer un commentaire