Problem Statement
In the game of bridge a hand consists of 13 or fewer cards from the deck. The values of the cards are ordered as shown above, with Ace having the highest value.
Suppose that hand is given as a
Create a class BridgeSort that contains a method sortedHand that is given a
Definition
- Class:
- BridgeSort
- Method:
- sortedHand
- Parameters:
- String
- Returns:
- String
- Method signature:
- String sortedHand(String hand)
- (be sure your method is public)
Constraints
- hand will contain an even number of characters between 2 and 26 characters inclusive.
- hand will contain a sequence of cards, each being a suit character followed by a value character as described in the problem statement.
- The cards in hand will be distinct.
Examples
"HAH2H3C4D5ST"
Returns: "C4D5H2H3HAST"
This hand contains the 4 of Clubs, which must come before all the other cards because Clubs comes before all the other suits. The 5 of Diamonds is next because Diamonds are the next suit. Next come the three Heart cards, in order of ascending value, namely 2 then 3 then Ace (which is represented by the A). Finally the 10 of Spades is last because of its suit.
"H3SAHA"
Returns: "H3HASA"
"C2"
Returns: "C2"
"C2C3C4C5C6C7C8C9CTCJCQCKCA"
Returns: "C2C3C4C5C6C7C8C9CTCJCQCKCA"
"HASADACA"
Returns: "CADAHASA"
"SAS2S3S4S5S6S7S8S9STSJSQSK"
Returns: "S2S3S4S5S6S7S8S9STSJSQSKSA"
"DAS2S3S4S5S6S7S8S9STSJSQSK"
Returns: "DAS2S3S4S5S6S7S8S9STSJSQSK"
"SAS2S3S4S5S6S7S8S9SKSJSQST"
Returns: "S2S3S4S5S6S7S8S9STSJSQSKSA"
"SAD2S3S4C5S6S7S8H9STSJHQCK"
Returns: "C5CKD2H9HQS3S4S6S7S8STSJSA"
"C2"
Returns: "C2"
"HJCJSJDJD8"
Returns: "CJD8DJHJSJ"
"HJCJSJDJD8CTC8CQ"
Returns: "C8CTCJCQD8DJHJSJ"
"HJCJSJDJD8C8S8H8"
Returns: "C8CJD8DJH8HJS8SJ"
"HJCJSJDJD8C4C3C2"
Returns: "C2C3C4CJD8DJHJSJ"
"SASKSQSJSTS9S8S7S6S5S4C3S2"
Returns: "C3S2S4S5S6S7S8S9STSJSQSKSA"
"HAH2H3C4D5ST"
Returns: "C4D5H2H3HAST"
"HAH9HTHJC4D5ST"
Returns: "C4D5H9HTHJHAST"
"HAH3HTC3CTD2D6DTS3STS7"
Returns: "C3CTD2D6DTH3HTHAS3S7ST"
"HQHK"
Returns: "HQHK"
"HKHQC2DKC7CQDQ"
Returns: "C2C7CQDQDKHQHK"
"C9CTCJ"
Returns: "C9CTCJ"
"DTD9"
Returns: "D9DT"
"DTDA"
Returns: "DTDA"
"HTH9H8H7C3S6S9DASAHACA"
Returns: "C3CADAH7H8H9HTHAS6S9SA"