Question: public class Exercise 0 4 _ Cards { / * The folks at Scamper Shipping like to play a bit of virtual poker at lunch,
public class ExerciseCards
The folks at Scamper Shipping like to play a bit
of virtual poker at lunch, Five Card Draw, no Jokers. The deck
is represented an array of strings, encoded as:
C through CJCQCKC
D through DJDQDKD
H through HJHQHKH
S through SJSQSKS
A hand is made up of a card array. For example:
HDSDS
Given a card array, return the value of the first card.
Examples:
getFirstCardHHHHHH
getFirstCardCDHSCC
getFirstCardKCQDJHSQCKC
public String getFirstCardString hand
return ;
One of the players feels lucky and discards the first card from their hand.
Given a card array, remove the first card, and return a new card
array made up of the second through fifth cards of the original array.
Note: The given card array is always guaranteed to have elements.
Examples:
discardFirstCardHHHHHHHHH
discardFirstCardCDHSCDHSC
discardFirstCardKCQDJHSQCQDJHSQC
public String discardFirstCardString hand
return new String;
Once a player has drawn the top card from the deck, they must discard it
Given a deck of cards, return a new deck containing all the cards except
the first from the original deck.
Note: The new array returned is one element shorter than the original,
except when the deck has no cards. Then the array returned must be empty.
Examples:
discardTopCardDHJCDSQCDHJCDSQCD
discardTopCardDSKDSKD
discardTopCardH
discardTopCard
public String discardTopCardString remainingDeck
return new String;
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
