Skip to content

gdotgordon/CardDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 

Repository files navigation

CardDemo

Card Deck implemented in Java. Compiled with JDK 8, should be compatible with JDK 7.

There isn't much grounbreaking code here - I was asked to model a deck of cards as a quiz question and share it on GitHub. So here it is.

Main classes are Card and Deck. There are embedded public Enums in Card for suit and rank. There is a comprehensive JUnit test called DeckTest that will verify the correctness of the code.

Usage:

try {

Deck d = new Deck();

d.shuffle();

if (!d.isEmpty()) {

    Card c = d.dealOneCard();

    Card.Suit suit = c.getSuit();

    Card.Rank rank = c.getRank();

    System.out.println("I drew card: " + c);

}

} catch (EmptyDeckException e) {

...

}

See comments in code for design justifications.

About

Card Deck in Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages