Android Open Source - pokerdrome Card Deck






From Project

Back to project page pokerdrome.

License

The source code is released under:

Pokerdrome was released under the GPLv3+ (https://www.gnu.org/licenses/gpl.html) by darlose pokerengine (https://code.google.com/p/pokerengine/) was released under the Apache License 2.0 (https://www...

If you think the Android project pokerdrome listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.darlose.pokerdrome;
//w ww .  java 2  s .  c om
import java.util.Random;

public class CardDeck 
{
  public Card[] cards;
  private int count;
  CardDeck()
  {
    Random r = new Random();
    cards = new Card[52];
    count = 0;
    for(int i=0;i<4;i++)
    {
      for(int j=0;j<13;j++)
      {
        cards[count] = new Card(Card.Rank.values()[j], Card.Suit.values()[i]);
        ++count;
      }
    }
    //Fisher-Yates/Knuth shuffling algorithm
    for(int i=0;i<52;i++)
    {
      int j = r.nextInt(51);
      Card temp = cards[j];
      cards[j] = cards[i];
      cards[i] = temp;
    }
  }
  public Card[] deal(int dcards)
  {
    Card[] dealt = new Card[dcards];
    for(int i=0;i<dcards;i++)
    {
      dealt[i] = cards[this.count-1];
      --this.count;
    }
    return dealt;
  }
}




Java Source Code List

com.darlose.pokerdrome.CardDeck.java
com.darlose.pokerdrome.Card.java
com.darlose.pokerdrome.Cards.java
com.darlose.pokerdrome.Deck.java
com.darlose.pokerdrome.Evaluate.java
com.darlose.pokerdrome.Game.java
com.darlose.pokerdrome.HandRank.java
com.darlose.pokerdrome.MainActivity.java
com.darlose.pokerdrome.Player.java
com.darlose.pokerdrome.Tables.java
com.darlose.pokerdrome.VideoPokerActivity.java