21/10/19, 11(04 pm
Problem Statement
A deck of cards contains 52 cards. Each card has a suit (Clubs, Diamonds, Hearts, or Spades) and a value (2, 3, , 9, 10, Jack, Queen, King, or Ace).
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 string giving the cards in the hand. Each card is represented by a suit character C, D, H, or S followed by a value character 2, 3, , 9, T, J, Q, K, or A. There are no spaces separating adjacent cards in hand.
Create a class BridgeSort that contains a method sortedHand that is given a string hand and that returns the string that represents the hand in sorted order. The proper order is to list all the cards that are Clubs, then all the Diamonds, then all the Hearts, and finally all the Spades, with the cards within each suit listed in order of ascending value.
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.
Thecardsinhandwillbedistinct. Examples
0)
1)
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
https://cs.adelaide.edu.au/users/second/pssd/15s2-pssd-adelaide/week10practice/BridgeSort/content.php Page 1 of 2
21/10/19, 11(04 pm
Returns: H3HASA
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.
https://cs.adelaide.edu.au/users/second/pssd/15s2-pssd-adelaide/week10practice/BridgeSort/content.php Page 2 of 2
Reviews
There are no reviews yet.