private void btnSelect_Click(object sender, EventArgs e) { Random random = new Random(); int num = random.Next(1, 3); MagicAnimal magicAnimal = MagicAnimalFactory.CreateMagicAnimal(num); lblRandom.Text = magicAnimal.Type; txtMessage.Text = magicAnimal.Show(); }
public static MagicAnimal CreateMagicAnimal(int n) { MagicAnimal mAnimal = null; switch (n) { case 1: mAnimal = new People("人族", "火器", 30); break; case 2: mAnimal = new Eidolon("精灵族", "弓箭", true); break; } return(mAnimal); }