Simplified poker shuffling and dealing procedures 简化的扑克牌洗牌发牌程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using MyLibrary;

namespace CardDeal
{
    class Program
    {
        static void Main(string[] args)
        {
            Card card=new Card();
            card.CardShuffle(card.Deck);
            card.CardDeal(card.Deck);
        }
    }
    class Card
    {
       public string[] Deck;
       public string[] DeckD;

        public Card()
        {
            Deck = new string[] 
            {
                                  "r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","rJ","rQ","rK","rA",
                                  "b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","bJ","bQ","bK","bA",
                                  "p1","p2","p3","p4","p5","p6","p7","p8","p9","p10","pJ","pQ","pK","pA",
                                  "s1","s2","s3","s4","s5","s6","s7","s8","s9","s10","sJ","sQ","sK" ,"sA" 
            };
        }

        public void CardShuffle(string[] Deck) {

            Console.WriteLine("Shuffle card:");
            Random random = new Random();
            string temp ;
            for (int i = 0; i < Deck.Length; i++)
            {
                int j = random.Next ()%(int)Deck.Length;
                temp = Deck[i];
                Deck[i] = Deck[j];
                Deck[j] = temp;
            }
            
            for (int i = 0;i < Deck.Length; i++)
            {
                
                Console.Write(Deck[i] + "   ");
                if (i == 13 || i == 27 || i == 41)
                Console.WriteLine();               
            }
            Console.WriteLine("\n");
        }
        public void CardDeal(string[] Deck)
        {
            Console.WriteLine("Deal a deck card:");
            string[] PartA=new string[Deck.Length/4];
            string[] PartB=new string[Deck.Length/4];
            string[] PartC=new string[Deck.Length/4];
            string[] PartD=new string[Deck.Length/4];
            for (int i = 0,j=0; i <Deck.Length; i += 4,j++) { 
                PartA[j] = Deck[i];
                PartB[j] = Deck[i+1];
                PartC[j] = Deck[i+2];
                PartD[j] = Deck[i+3];
            }
            Console.Write("PartA[i]:" +"  " +"PartB[i]: "+ "  " + "PartC[i]:" + "  " + "PartD[i]:" + "\n");
            for (int i = 0; i < Deck.Length / 4; i++) {
                Console.Write("   "+PartA[i] + "        " + PartB[i] + "          " + PartC[i] + "         " + PartD[i] + "\n");
            }
            Console.WriteLine();
        }

    }
    
}

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值