Question
Implement a CardHand class that supports a person arranging a group of cards in his or her hand. The simulator should represent the sequence of
Implement a CardHand class that supports a person arranging a group of cards in his or her hand. The simulator should represent the sequence of cards using a single positional list ADT so that cards of the same suit are kept together. Implement this strategy by means of four fingers into the hand, one for each of the suits of hearts, clubs, spades, and diamonds, so that adding a new card to the persons hand or playing a correct card from the hand can be done in constant time. The class should support the following methods:
addCard(r, s): Add a new card with rank r and suit s to the hand.
play(s): Remove and return a card of suit s from the players hand; if there is no card of suit s, then remove and return an arbitrary card from the hand.
iterator( ): Return an iterator for all cards currently in the hand.
suitIterator(s): Return an iterator for all cards of suit s that are currently in the hand.
--> PLUS THERE IS AN ADDITIONAL INFORMATION GIVEN BY OUR INSTRUCTOR.
Based on the description of the Card class in the assignment it may make more sense to define the addCard methods as:
addCard( Card newCard)
instead of the
addCard( rank, suit ) described in the text.
You may choose which method you wish to impleme
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started