Dr. Wildenberg Final project C.

 

The problem(s):

 

1.    Classify the hand as to it’s poker type. This is a complex question to which I do not know a “best” method.  For reference, here are the names and definitions of Poker hands from lowest to highest and information about breaking ties.

 

A.   X-high, where X is A, K, Q, 10, 9, 8, 7, 6, 5, 4, 3, or 2.  For example a “King high”.  This means that the hand is none of the types below and is called by the name of its highest card. The higher X is, the better the hand; A is high.

B.    A Pair.  Two cards of the same number, the other three do not match each other or the pair. Higher pairs beat lower pairs.

C.   Two Pairs. Two cards of some number and two cards of a second number, and the fifth card not matching. For two hands of this type, the highest pair wins; if both higher pairs are the same, we compare the lower pairs; if there’s still a tie, we compare the odd card.

D.   Three of a kind.  Three cards of the same number and two cards which do not match.  Compare the number of the triple.  If they’re the same (possible with wild cards), compare the highest odd card.  If still tied, compare the lower odd card.

E.    Straight.  All five cards are in numerical sequence, but not all the suits are the same.  Note that A is either high or low but can not be in the middle.  Thus (A, 2, 3, 4, 5) and (T,J.Q,K,A) and (5,6,7,8,9) are all “straights”, but (J,Q,K,A,2) is not. (A,2,3,4,5) is the lowest straight and (T,J,Q,K,A) is the highest.

F.    Flush.  All cards of the same suit, but not in numerical sequence.  Flushes are compared by comparing the highest card, then (if tied) the next highest, etc.

G.   Full house. Three cards of the same number and two cards of the same number. Compare first the triple, then the pair.

H.   Four of a kind. Four cards of the same number.  Compare the four, then the odd card.

I.     Straight Flush.  Both a straight and a flush. (The Ace high straight flush is called a royal flush.)

 

 

2.    EC: An even more challenging problem is to compare two poker hands.  That would involve classifying each and then handling the cases where each was of the same type.

 

I will post a test file.  The test will contain a series of lines like these:

 

4S3D6S5S2S

ACTD4H5H6H  (note that T stands for 10)

 

Your job is to print the hand and the classification above.

 

This assignment will be graded on good programming style, organization, how completely it accomplishes the task, documentation.  You will probably want lots of functions to do various things.  You may want to be able to sort a hand.