ou must write a function for each hand type. Each function must accept a const int array that contains HAND_SIZE integers, each representing one of the HAND_SIZE cards in the hand, and must return "true" if the hand contains the cards indicated by the name of the function, "false" if it does not. The functions must have the following prototypes. bool containsPair(const int hand[]); bool containsTwoPair(const int hand[]); bool containsThreeOfaKind(const int hand[]); bool containsStraight(const int hand[]); bool containsFullHouse(const int hand[]); bool containsFourOfaKind(const int hand[]); Important! In the descriptions below, a pair is defined as exactly two of the same card. If there are more than two of the same card, that is not a pair. Similarly, a three-of-a-kind is defined as exactly three of the same card. If there are more than three of the same card, that is not a three-of-a-kind. However! Since there is no such hand as five-of-a-kind or more, four-of-a-kind must return true if there are four or more of the same card. // post: returns true if and only if there are one or more pairs in the hand. Note that // this function returns false if there are more than two of the same card (and no other pairs). bool containsPair(const int hand[]); // post: returns true if and only if there are two or more pairs in the hand. bool containsTwoPair(const int hand[]); // post: returns true if and only if there are one or more three-of-a-kind's in the hand. bool containsThreeOfaKind(const int hand[]); // post: returns true if there are 5 consecutive cards in the hand. bool containsStraight(const int hand[]); // post: returns true if there is are one or more pairs and one or more three-of-a-kind's in the hand. bool containsFullHouse(const int hand[]); // post: returns true if there are one or more four-of-a-kind's in the hand. bool containsFourOfaKind(const int hand[]); A hand that contains three-of-a-kind and two other different cards (for example, 1, 1, 1, 2, 3) should return "false" for "containsPair()" A hand that contains four-of-a-kind should return "false" for "containsPair()" and "containsThreeOfaKind()" A hand that contains a full-house should return "true" for containsThreeOfaKind() and containsPair(). A hand that contains two-pair should return "true" for containsPair(). 2) You do not need to write a containsHighCard function. All hands contain a highest card. If you determine that a particular hand is not one of the better hand types, then you know that it is a High Card hand. 3) Do not sort the cards in the hand. Also, do not make a copy of the hand and then sort that. 4) An important objective of this assignment is to have you practice creating excellent decomposition. Don't worry about efficiency on this assignment. Focus on excellent decomposition, which results in readable code. This is one of those programs where you can rush and get it done but end up with code that is really difficult to read, debug, modify, and re-use. If you think about it hard, you can think of really helpful ways in which to combine the tasks that the various functions are performing.
Additional Requirements
1) You must write a function for each hand type. Each function must accept a const int array that contains HAND_SIZE integers, each representing one of the HAND_SIZE cards in the hand, and must return "true" if the hand contains the cards indicated by the name of the function, "false" if it does not. The functions must have the following prototypes.
bool containsPair(const int hand[]);
bool containsTwoPair(const int hand[]);
bool containsThreeOfaKind(const int hand[]);
bool containsStraight(const int hand[]);
bool containsFullHouse(const int hand[]);
bool containsFourOfaKind(const int hand[]);
Important! In the descriptions below, a pair is defined as exactly two of the same card. If there are more than two of the same card, that is not a pair. Similarly, a three-of-a-kind is defined as exactly three of the same card. If there are more than three of the same card, that is not a three-of-a-kind. However! Since there is no such hand as five-of-a-kind or more, four-of-a-kind must return true if there are four or more of the same card.
// post: returns true if and only if there are one or more pairs in the hand. Note that
// this function returns false if there are more than two of the same card (and no other pairs).
bool containsPair(const int hand[]);
// post: returns true if and only if there are two or more pairs in the hand.
bool containsTwoPair(const int hand[]);
// post: returns true if and only if there are one or more three-of-a-kind's in the hand.
bool containsThreeOfaKind(const int hand[]);
// post: returns true if there are 5 consecutive cards in the hand.
bool containsStraight(const int hand[]);
// post: returns true if there is are one or more pairs and one or more three-of-a-kind's in the hand.
bool containsFullHouse(const int hand[]);
// post: returns true if there are one or more four-of-a-kind's in the hand.
bool containsFourOfaKind(const int hand[]);
- A hand that contains three-of-a-kind and two other different cards (for example, 1, 1, 1, 2, 3) should return "false" for "containsPair()"
- A hand that contains four-of-a-kind should return "false" for "containsPair()" and "containsThreeOfaKind()"
- A hand that contains a full-house should return "true" for containsThreeOfaKind() and containsPair().
- A hand that contains two-pair should return "true" for containsPair().
2) You do not need to write a containsHighCard function. All hands contain a highest card. If you determine that a particular hand is not one of the better hand types, then you know that it is a High Card hand.
3) Do not sort the cards in the hand. Also, do not make a copy of the hand and then sort that.
4) An important objective of this assignment is to have you practice creating excellent decomposition. Don't worry about efficiency on this assignment. Focus on excellent decomposition, which results in readable code. This is one of those programs where you can rush and get it done but end up with code that is really difficult to read, debug, modify, and re-use. If you think about it hard, you can think of really helpful ways in which to combine the tasks that the various functions are performing.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images