AP Computer Science, Cards

Creative Commons License
Material accessible from this web page that was created by Owen Astrachan is licensed under a Creative Commons License.

This material augments a written description of how to develop classes and code for implementing playing cards. That description is copyright the College Board, that description is here as a PDF.

The card images shown in the royal flushes below are accessible here and are licensed under the GPL (original card site)

ten spades jack spades queen spades king spades ace spades

ten hearts jack hearts queen hearts king hearts ace hearts


Here's the code in a tgz file unpacking should be simple. See, in particular, the README file describing some of the classes that aren't in the original workshop materials.

In particular, testing a deck implementation isn't completely straightforward or obvious. The code in DeckTest.java shows some rudimentary checks on whether a shuffled Deck has the right cards in it. When run, the testing program prints nothing if all tests pass, otherwise errors in testing are printed.

There's the beginning of an integrated Model/View class for playing video poker. I'll separate the Model from the View sometime soon (like when someone emails me saying "now please"). The GUI code in either SimpleGuiTester.java or the similar, but more general RealGuiTester.java are closer to a separate View, but they're for testing hands, not playing video poker.


Owen L. Astrachan
Last modified: Thu Dec 17 15:29:45 EST 2015