Exemple #1
0
        //扑克牌生成
        static List <brand> RandomLicensing()
        {
            List <brand> myCards = new List <brand>();//扑克牌集合

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

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

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

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

            return(stackCard);
        }
        public void sort()
        {
            brand temporary = new brand();

            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);
                    }
                }
            }
        }
Exemple #3
0
 //传入数值更新
 public void update(brand a)
 {
     this.Type      = a.Type;
     this.Name      = a.Name;
     this.Cardvalue = a.Cardvalue;
 }
 public void c(brand a)
 {
     listCard.Add(a);
 }