pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

C# paste-bin - collaborative debugging tool View Help


Posted by Anonymous on Wed 11th Jul 11:00
download | new post

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Collections;
  5.  
  6. namespace JokersWorld
  7. {
  8.     class Cards
  9.     {
  10.         private Hashtable m_Cards = new Hashtable(52);
  11.         private ArrayList m_CurrentCards = new ArrayList();
  12.         private Hashtable m_CardsToHold = new Hashtable(5);
  13.         private int m_CardsInHand = 0;
  14.  
  15.         public void ShuffleWithHold()
  16.         {
  17.             for ( int i = 1; i < 6; i ++)
  18.             {
  19.                 if ((bool)m_CardsToHold[i] == true)
  20.                     m_CardsInHand += 1;
  21.                 else
  22.                 {
  23.                     m_Cards[m_CurrentCards[i-1]] = false;
  24.                     m_CurrentCards.Remove(m_CurrentCards[i-1]);
  25.                 }
  26.             }
  27.         }
  28.  
  29.         public int PopForHold()
  30.         {
  31.             if (m_CardsInHand != 5)
  32.             {
  33.                 Random rnd = new Random();
  34.                 int card = rnd.Next(52);
  35.  
  36.                 while (Convert.ToBoolean(m_Cards[card]) == true)
  37.                 {
  38.                     card = rnd.Next(52);
  39.                 }
  40.  
  41.                 m_Cards[card] = true;
  42.  
  43.                 m_CurrentCards.Add(card);
  44.  
  45.                 m_CardsInHand += 1;
  46.  
  47.                 m_CardsToHold[m_CardsInHand] = false;
  48.  
  49.                 return card;
  50.             }
  51.  
  52.             return 0;
  53.         }
  54.  
  55.         public void Shuffle()
  56.         {
  57.             for (int i = 0; i < 53; i++)
  58.             {
  59.                 m_Cards[i] = false;
  60.             }
  61.  
  62.             m_CardsInHand = 0;
  63.         }
  64.  
  65.         public void Trigger(int pos)
  66.         {
  67.             m_CardsToHold[pos] = !(bool)m_CardsToHold[pos];
  68.         }
  69.  
  70.         public int Pop()
  71.         {
  72.             if (m_CardsInHand != 5)
  73.             {
  74.                 Random rnd = new Random();
  75.                 int card = rnd.Next(52);
  76.                
  77.                 while ( Convert.ToBoolean(m_Cards[card]) == true )
  78.                 {
  79.                     card = rnd.Next(52);
  80.                 }
  81.  
  82.                 m_Cards[card] = true;
  83.  
  84.                 m_CurrentCards.Add(card);
  85.  
  86.                 m_CardsInHand += 1;
  87.  
  88.                 m_CardsToHold[m_CardsInHand] = false;
  89.  
  90.                 return card;
  91.             }
  92.  
  93.             return 0;
  94.         }
  95.  
  96.         public string GetName(int Card)
  97.         {
  98.             string CardName = "";
  99.             if (Card < 13) CardName = "Hjärter ";
  100.             else if (Card < 26 && Card > 12) CardName = "Ruter ";
  101.             else if (Card < 39 && Card > 25) CardName = "Klöver ";
  102.             else if (Card < 52 && Card > 38) CardName = "Spader ";
  103.             else if (Card == 52) CardName = "Joker";
  104.  
  105.             if (Card != 52)
  106.             {
  107.                 bool Small = true;
  108.                 switch (Card)
  109.                 {
  110.                     case 0:
  111.                     case 13:
  112.                     case 26:
  113.                     case 39:
  114.                         CardName += "Ess";
  115.                         Small = false;
  116.                         break;
  117.  
  118.                     case 10 :
  119.                     case 23 :
  120.                     case 36 :
  121.                     case 49 :
  122.                         CardName += "Knekt";
  123.                         Small = false;
  124.                         break;
  125.  
  126.                     case 11:
  127.                     case 24:
  128.                     case 37:
  129.                     case 50:
  130.                         CardName += "Dam";
  131.                         Small = false;
  132.                         break;
  133.  
  134.                     case 12:
  135.                     case 25:
  136.                     case 38:
  137.                     case 51:
  138.                         CardName += "Kung";
  139.                         Small = false;
  140.                         break;
  141.  
  142.                 }
  143.  
  144.                 if (Small)
  145.                 {
  146.                     switch (Card)
  147.                     {
  148.                         case 1:
  149.                         case 14:
  150.                         case 27:
  151.                         case 40:
  152.                             CardName += "2";
  153.                             break;
  154.                         case 2:
  155.                         case 15:
  156.                         case 28:
  157.                         case 41:
  158.                             CardName += "3";
  159.                             break;
  160.                         case 3:
  161.                         case 16:
  162.                         case 29:
  163.                         case 42:
  164.                             CardName += "4";
  165.                             break;
  166.                         case 4:
  167.                         case 17:
  168.                         case 30:
  169.                         case 43:
  170.                             CardName += "5";
  171.                             break;
  172.                         case 5:
  173.                         case 18:
  174.                         case 31:
  175.                         case 44:
  176.                             CardName += "6";
  177.                             break;
  178.                         case 6:
  179.                         case 19:
  180.                         case 32:
  181.                         case 45:
  182.                             CardName += "7";
  183.                             break;
  184.                         case 7:
  185.                         case 20:
  186.                         case 33:
  187.                         case 46:
  188.                             CardName += "8";
  189.                             break;
  190.                         case 8:
  191.                         case 21:
  192.                         case 34:
  193.                         case 47:
  194.                             CardName += "9";
  195.                             break;
  196.                         case 9:
  197.                         case 22:
  198.                         case 35:
  199.                         case 48:
  200.                             CardName += "10";
  201.                             break;
  202.                     }
  203.  
  204.                 }
  205.             }
  206.  
  207.             return CardName;
  208.            
  209.         }
  210.     }
  211. }

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@
:
:
Remember my settings