Assignment #5 -- Designing a card deck class
Due: Mon, April 2
Objective
To practice with class design in Java, using good design principles as
discussed in class. Also to gain further practice with Java compilation
and execution of programs.
Task
You are to design and implement, in Java, a CardDeck class. The
intent is to create a class that is versatile enough to be a re-usable
module in the implementation of a variety of card games. You will create
and your own design and interface, keeping with good class design
principles.
Details
- General class requirements
- Create a class called CardDeck, in the file
CardDeck.java
- Create a class called Card, to represent a single card.
You'll need this because some CardDeck methods may need to
return one or more cards to the caller
- You may create other classes if you like, to be used by
CardDeck. Make sure any other classes are well-documented
- Even if you create other classes, remember that the primary focus of
this task is to build a card deck module (not a full program based on
any specific card game).
- Desired features of the Card class
Your Card class should provide at least the following
features, for easy use and testability
- Desired features of the card deck
Your CardDeck class should provide at least the following
features as part of its interface
- Documentation
- Remember to use good design principles
Your class will be judged partly on use of good design principles,
including:
- Quality of interface: cohesion, completeness, convenience, clarity,
consistency
- Following good encapsulation principles (private data, public
methods, Law of Demeter)
- Clear accessors and mutators, where appropriate
- Avoiding unintended side effects. (i.e. there shouldn't be anything
that takes the user by surprise!)
- Good documentation of contracts (invariants, preconditions,
postconditions)
- Demonstration of Class Features
Write at least one test program that demonstrates class features.
- You may write more than one "main" test program if you like.
- Some hard-coded test cases are fine, but you should include some
mechanism for interactive testing, as well
- Suggestion: One test program with hard-coded calls. One allowing
interactive testing
- Some example of good interactive testing in a driver test program
- Allow a user (from standard input) to enter what type of deck to
create
- Allow a user to choose different deck options -- like shuffling,
printing the deck contents, dealing a card (or cards) and seeing
what was dealt, or retrieving the value or suit of a dealt card
- Menu driver programs are good for this kind of thing. Allowing the
user to call upon different features, in the order of their
choosing
- Create a "README" file (text format is fine) that explains your test
program(s). Specifically, make it clear to your reader (i.e. your
instructor/grader) how your test routines can be used to thoroughly
demonstrate your class features, including any erroneous uses (like
the caller violating a precondition) and the responses by your
class. You are welcome to include any other explanatory material in
your README that helps document your design
Submitting
Remember to compile and test Java code on either
program.cs.fsu.edu or linprog.cs.fsu.edu.
To prepare your submission, bundle all of your files (code files,
README) into a single "jar" archive called "hw5.jar". Format:
jar cvf hw5.jar
For example, if all of the files to bundle are in one directory (and
nothing else), you can pack it up with this:
jar cfv hw5.jar * // packs all files in the current directory
jar cfv hw5.jar *.java README // or use this one, for code files and README
E-mail this jar file (hw5.jar) to me (myers@cs.fsu.edu) by the due
date. Your e-mail subject should be HW5-SUBMIT. Include your name
and section in the e-mail body. Please only submit ONCE, unless you make
a mistake and need to correct it (before the due date) -- and minimize
this. Only the last submission will be graded.
Your submission e-mail needs to come either from your CS account
(preferred) or your garnet/mailer account.