//扑克牌生成
        static List <num> RandomLicensing()
        {
            List <num> myCards = new List <num>();//扑克牌集合

            string[] strType   = { "红桃", "黑桃", "梅花", "方块" };
            string[] strNumber = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
            num[]    OtherCard = { new num("大王", ""), new num("小王", "") };

            myCards.Add(OtherCard[0]);
            myCards.Add(OtherCard[1]);
            for (int i = 0; i < strType.Length; i++)
            {
                for (int t = 0; t < strNumber.Length; t++)
                {
                    num p = new num(strType[i], strNumber[t]);
                    myCards.Add(p);
                }
            }

            //洗牌
            List <num> stackCard = new List <num>();
            Random     r         = new Random(); //随机数生成器

            while (myCards.Count > 0)            //元素转移,转移后移除扑克,新集合中见
            {
                int iIndex = r.Next(0, myCards.Count);
                stackCard.Add(myCards[iIndex]);
                myCards.RemoveAt(iIndex);
            }

            return(stackCard);
        }
예제 #2
0
        public void sort()
        {
            num temporary = new num();

            for (int y = 0; y < listCard.Count - 1; y++)
            {
                for (int c = 0; c < listCard.Count - 1 - y; c++)
                {
                    if (listCard[c].Cardvalue < listCard[c + 1].Cardvalue)
                    {
                        temporary.update(listCard[c + 1]);
                        listCard[c + 1].update(listCard[c]);
                        listCard[c].update(temporary);
                    }
                }
            }
        }
예제 #3
0
 //传入数值更新
 public void update(num a)
 {
     this.Type      = a.Type;
     this.Name      = a.Name;
     this.Cardvalue = a.Cardvalue;
 }
예제 #4
0
 public void c(num a)
 {
     listCard.Add(a);
 }