Question: Program Speci cation: You are to write a Class Deck which emulates a full deck of playing cards. That is 4 suits ( Clubs ,
Program Speci cation:
You are to write a Class Deck which emulates a full deck of playing cards. That is suits Clubs Spades,
Hearts, and Diamonds and ranks Ace Jack, Queen, King in each suit. This of
course makes for a total of playing cards in the deck.
Mandatory Instance variable:
private boolean deck new boolean;
Mandatory Instance and Class methods:
public void initDeck
set the values of deck to indicate that they are all
pressent not delt yet.
public boolean emptyDeck
returns wheather or not all the cards in the deck
have already been delt.
public int dealCard
returns a card an int in the range to at random
that has not been delt since the deck was initialize
via intDeck. Also notes in deck that this card is
no longer available.
public static String cardToStringint card
given a card an int in the range to returns
an appropriate String repressentation of this card
based on a and onto mapping of the set
to the cards described above.
You are also to write a Driver Class DeckDriver to test your Deck class.
Mandatory Functionality:
Your driver class must minimally print all the cards in the deck in the random order that they are dealt
Such as in Program
Rules and Requirements:
All access to the instance variables in your deck classes instance methods must be made via this.
Notes and Hint:
You should be able to reuse much of your methods code from Program in writing your deck class.
You should be able to rewrite your main method from Program into your driver class with
minimal modi cation e ort.
Lastly you are to write a second deck class SmartDeck which adds a second instance variable cardsDealt
that at all times contains the number of cards dealt since that last call to initDeck
Notes and Hint:
cardsDealt will need to be modi ed by initDeck and dealCard and will allow you to write
emptyDeck without the use of a loop.
YourDeckDriver class must also work identically whether myDeck is declared as Deck or SmartDeck.
Sample runs:
Run : with Deck class
Here is a shuffled deck
S KS H S C D D C
H C H D H D S S
JH AH S KC QC AD QD D
AS KD C H KH C JC C
D H AC S C JS H S
D D S C QH C JD S
QS D H H
Run : with SmartDeck class
Here is a shuffled deck
D C AD C JC JH KS S
C S S AC QS C H C
S QC AS D S C S D
S H H S JD KD QH D
H QD D H D H D H
KH AH D C D S C H
KC JS C
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
