
School of Engineering and Applied Science
Department of Computer Science
CSci 53 -- Introduction to Software Development
http://www.seas.gwu.edu/~csci53/spring04
Alice Armstrong
Project 7
due Tuesday 4/13/04
This is a firm dead line. If you turn this project in late, you will lose 10 points from project 8 in addition to late fees for this project!
Motivation:
Writing clear, well-documented, correct, well-tested code is not just something that you are forced to do in school and that you can stop doing as soon as you get out into the "real world". Most of the time, you will be extending the work of someone who worked on a project before you. Also, most work in industry is done in teams.
In this project, you will develop and test a class that will be used as the basis for project 8. To give you a taste of what is to come, you will hand off the work for this project to someone else and you will complete project 8 using the class that one of your classmates developed.
Therefore, it is vitally important that you do two things in the project: develop, document, and test this project as throughly as you can; and complete your work on time.
If you do not complete this project on time, you will use your own work for project 8. But, since you will be missing half of the intended experience, you will automatically lose 10 points from project 8.
Keep in mind that I will not drop grades from project 7 or 8.
What To Submit:
In addition to the standard paper materials, you must also submit electronic copies of your projects 6 & 7 to me (
). I need everything you wrote or created for both projects:
- Analysis
- Data Requirements
- Algorithms
- Code for classes, applications, & test programs
- Test Plans
- .turnin files
I will be stripping all identifying info from your two projects and the redistributing your code to one of your classmates. Likewise you will receive someone else's code and documentation which you will use to build an application for project 8.
Your email to me must be received by 8pm Tuesday night 4/13/04.
If I do not have it by then, your project wil be considered late.
Specification:
Step 1)
Create a class called Deck that represents a deck of 52 cards (a standard deck without any jokers).
Your class should include the following, private instance variables:
- private Card[] cards;
an array which holds 52 Cards always in order, for reference
positions 0-12 should hold the Heart suit in the order {Ace, 2, 3, ..., Queen, King}
positions 13-25 should hold the Club suit in the order {Ace, 2, 3, ..., Queen, King}
positions 26-38 should hold the Diamond suit in the order {Ace, 2, 3, ..., Queen, King}
positions 39-51 should hold the Spade suit in the order {Ace, 2, 3, ..., Queen, King}
this array never changes
- private int[] theDeck;
an array of 52 integers
each integer represents a postion in the cards array.
this is the array that gets shuffled
- private boolean[] dealt;
an array which holds boolean values which represent if the Card at a given position has been dealt
(true) or is still in the deck (false)
- private int numCardsLeft;
an integer representing the number of cards left in the deck
Your class should implement the following public methods:
- public Deck();
a Constructor
initializes the cards array and shuffles theDeck array
- public void shuffle();
returns all the cards to the deck and randomly reorders them, using theDeck array
download ShuffleDemo.java here for hints on this method
- public Card[] deal(int numCards);
if there are at least numCards left in the deck, removes numcard many cards from the deck and returns a
Card array of size numCard
only cards that are still in the deck may be dealt
if there are not enough cards in the deck, prints an error message and returns null
- public int howManyCardsLeft();
returns the number of cards left in the deck
- public String shuffledDeck();
returns a String that represents the remaining cards in the deck in their shuffled order
- public String unshuffledDeck();
returns a String that represents the remaining cards in the deck in their unshuffled order
- public String toString();
returns a String that represents the cards left in the deck in their shuffled order and then again in their unshuffled order
Step 2)
Test your class by writing a driver program.
Notes)
As in project 5, you must write up both classes that you create.
(end of assignment)