ID NUMBER:0970584 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { } } class PlayingCard { public PlayingCard() { int conut; int[] card = new result[52]; //set a new array card[] to store the random 52 cards for (count = 0; count < 26; count++) { card1[count]=card[count]; //send random 26 cards to player1 card2[count] = card[52 - count]; //send random 26 cards to player2 } int[] card1=new int[52]; //set the array to store the first 26 cards int[] card2=new int[52]; //set the array to store the second 26 cards for (i = 0; i < 52; i++) { if (card2[i].Text == card1[i].Text) // if the value of the two cards are same for (int j = 0; j < i; j++) { card1[j] = null; //put the first array number to null if (iswin()) //if the player1 no cards to sent { MessageBox.Show("the winner is player1", MessageBoxIcon.Information); } card2[j] = null; if (iswin()) { MessageBox.Show("the winner is player2", MessageBoxIcon.Information); } if(!card1first) //if player1 lay cards first and player2 wins card2[52-i]=card1[j]; //put the player1's laid cards at the bottom of player2's card2[52-i-j]=card2[j]; //put the player2's laid cards at the bottom of player2's Console.WriteLine("player1 wins the cards"); if(card1first) //if player2 lay cards first and player1 wins card1[52 - i] = card2[j]; //put the player2's laid cards at the bottom of player1's card1[52 - i - j] = card1[j]; //put the player1's laid cards at the bottom of player1's Console.WriteLine("player2 wins the cards"); card1first = true; card1[j] = card1[j + j]; //put the j+j cards instead of front cards, and the next round the first player will show the card[0] "the top card at deck" card2[j] = card2[j + j]; } } } public bool iswin() { bool win = true; win = ((card1[52] == null) || (card2[52] = null));//if the one player with no cards loses } } class DeckofCards //random the 52 cards { public int[] ArrayRandom() //random function { int[] index = new int[52]; // the total number of cards is 52 for (int i = 0; i < 52; i++) index[i] = i; Random rand = new Random(); //set a new random array to keep the random 52 cards int[] result = new int[52]; int count = 52; int id; int num = count; for (int j = 0; j < 52; j++) //define the number of random cards { id = rand.Next(0, count - 1); result[j] = index[id]; //put the random 52 cards data in the array result[] index[id] = index[count - 1]; count--; } return result; } } class Player { public Player(string n1,string n2) { name1 = n1; name2 = n2; } public string n1 //get the first player's name { get{return name1;} set { name1 = value; } } public string n2 //get the second player's name { get { return name2; } set { name2 = value; } } public void printplayerInfo() { Console.WriteLine("Players are {0} and {1}:", name1, name2); //print the two players' names } private string name1,name2; } class CardGame { public CardGame() { InitializeComponent(); // initialize the game } bool card1first = false; //define the card1first'false' for know which one is the first send card private int[] ArrayRand=new int[52]; public int[] result=new int[52]; private void start_Click(object sender, EventArgs e) //start the new game { start.Click += new System.EventHandler(this.btn_Oper); } private void pause_Click(object sender, EventArgs e) //pause the game { pause.Click += new System.EventHandler(this.btn_Oper); } } class Test { static void Main(string[] args) { Player player = new Player("Simon", "Tomans"); //test two players "simon" and "Tomans" PlayingCard(); // run the function of PlayingCard() CardGame(); //run the function of CardGame() ArrayRandom(); //run the Deckofgame() } } }