An open API service indexing awesome lists of open source software.

https://github.com/locka99/deckofcards

A set of classes that efficiently simulate a deck of cards
https://github.com/locka99/deckofcards

Last synced: about 1 year ago
JSON representation

A set of classes that efficiently simulate a deck of cards

Awesome Lists containing this project

README

          

This is an implementation of a deck of cards written in Java and released under
the LGPLv3. This code forms the core of the ad-supported Android application
ShuffleBot which calculates Texas Hold 'Em odds.

ShuffleBot runs hundreds / thousands of game simulations on mobile devices
so implementation of a deck is geared towards optimal performance while
maintaining a simple programming API.

See the COPYING file for more information about LGPLv3.

DeckOfCards project home:

https://github.com/locka99/DeckOfCards

For info about ShuffleBot see here:

https://market.android.com/details?id=com.shufflebot
http://www.shufflebot.com/

For development musings related to DeckOfCards and ShuffleBot subscribe to this feed:

https://joindiaspora.com/tags/shufflebot

Primary classes:

Deck Represents a deck which consists of 52 cards which are drawn or
undrawn or some combination of the two.
Card A card within a deck. Note cards are immutable and only 52 ever exist
irrespective of the number of references to them.
CardPattern A wildcard that represent one or more cards based on a pattern.
CardSuit The suit of a card
CardValue The value of a card.
Random A random number generator. It utlitises either the standard Java RNG or
a secure RNG depending on how it is called.

Build instructions:

You build using Maven like so:

mvn clean install

Add DeckOfCards to another project by including a dependency on this POM, e.g.

com.adamlock
DeckOfCards
1.0-SNAPSHOT

For use in GWT, import the DeckOfCards project into your build and add this line to your module:

Using it:

Deck deck = new Deck();
deck.shuffle();
Card []cards = deck.deal(5);
for (Card card : cards) {
System.out.println("You dealt " + card);
}