Exemplo n.º 1
0
 public override void acceptCard(Card card)
 {
     if (pile.Count != 0) {
         pile .Insert (0, card);
     }
     acceptCard(card);
 }
Exemplo n.º 2
0
 /* <summary>
  * Get the top face up card
  * </summary>
  */
 public Card getTopFaceUp(Card card)
 {
     if (!isEmpty())
       {
     throw new Exception("There are currently no cards available. "
                         + "Please add a card to continue");
       }
       else
       {
     AddCard(card);
       }
       return cardList[cardList.Count - 1];
 }
Exemplo n.º 3
0
        public void createDeck()
        {
            for (int i = 0; i < 4; i++)
            {
                int count = 0;

                for(int j = i * CARDRANKRANGE; j < (i + 1) * CARDRANKRANGE; j++)
                {
                    cardstack[j] = new Card((CardSuit)i, count);
                    count++;

                    Console.WriteLine("Card #" + j +  " " + cardstack[j].Suit + cardstack[j].faceRank());

                }
            }
        }
Exemplo n.º 4
0
 //will add a card to the pile
 public abstract void AddToPile(Card card);
Exemplo n.º 5
0
 public abstract void acceptCard(Card card);
Exemplo n.º 6
0
 /* <summary>
  * Adds a card to the pile
  * @param: Cards card
  * </summary>
  */
 public override void AddToPile(Card card)
 {
     if (pile.Count == 0) {
         pile.Add (card);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Removes card from the waste pile
 /// </summary>
 public void removeCard(Card card)
 {
     pile.Remove(card);
 }
        private void CalculationGame_Load(object sender, EventArgs e)
        {
            //Load cards. We will use threads to speed up the way cards are loaded
              string[]cards=System.IO.Directory.GetFiles(System.IO.Path.GetFullPath("../cards/"));

              /*
              foreach (string card in cards)
              {
            if (!card.ToLower().Contains("Thumbs.db".ToLower()) && !card.ToLower().Contains("b2fh.gif".ToLower()))
            {
              string fileName = System.IO.Path.GetFileName(card);
              deck.AddCard(new Card(fileName));
            }
              }
               */

              Parallel.ForEach(cards, card =>
            {
              if (!card.ToLower().Contains("Thumbs.db".ToLower()) && !card.ToLower().Contains("b2fh.gif".ToLower()))
              {
            string fileName = System.IO.Path.GetFileName(card);
            deck.AddCard(new Card(fileName));
              }

            });

              Card card1 = new Card("1.gif");
              Card card2 = new Card ("16.gif");
              Card card3 = new Card("30.gif"); ;
              Card card4 = new Card("44.gif");

              Bitmap image1 = card1.getCardImage();
              Bitmap image2 = card2.getCardImage();
              Bitmap image3 = card3.getCardImage();
              Bitmap image4 = card4.getCardImage();

              foundation1.BackgroundImage = image1;
              fPile_1.AddToPile(card1);
              foundation2.BackgroundImage = image2;
              fPile_2.AddToPile(card2);
              foundation3.BackgroundImage = image3;
              fPile_3.AddToPile(card3);
              foundation4.BackgroundImage = image4;
              fPile_4.AddToPile(card4);

              deck.removeCard(card1);
              deck.removeCard(card2);
              deck.removeCard(card3);
              deck.removeCard(card4);

              dPile1LastCardLocation = panel1.Location;
              dPile2LastCardLocation = panel2.Location;
              dPile3LastCardLocation = panel3.Location;
              dPile4LastCardLocation = panel4.Location;

              textBox1.Text = "2 3 4 5 6 7 8 9 10 J Q K";
              textBox2.Text = "4 6 8 10 Q A 3 5 7 9 J K";
              textBox3.Text = "6 9 Q 2 5 8 J A 4 7 10 K";
              textBox4.Text = "8 Q 3 7 J 2 6 10 A 5 9 K";

              //MessageBox.Show("FPile " + fPile.getCount().ToString());
              //MessageBox.Show("Deck " + deck.getCount().ToString());
        }
Exemplo n.º 9
0
        /* <summary>
         * Compares two cards based on their
         * </summary>
         */
        public void compareTwoCards(Card card1, Card card2)
        {
            bool flag = true;
              if (card1.getCardName() != card2.getCardName() && flag)
              {
            flag = false;
              }

              if (card1.getCardNumber() != card2.getCardNumber() && flag)
              {
            flag = false;
              }

              if (card1.getCardColor() != card2.getCardColor() && flag)
              {
            flag = false;
              }

              if (card1.getCardSuit() != card2.getCardSuit() && flag)
              {
            flag = false;
              }
        }
Exemplo n.º 10
0
 /* <summary>
  * Adds a card to the pile
  * @param: Cards card
  * </summary>
  */
 public void AddCard(Card card)
 {
     cardList.Add (card);
 }
Exemplo n.º 11
0
 /* <summary>
  * This method will accept a card <br>
  * A card will be inserted at the first <br>
  * position of a list
  * </summary>
  */
 public void acceptCard(Card card)
 {
     if (!isEmpty()) {
         cardList.Insert (0, card);
     }
 }