Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* In most Poker games, the "full house" hand is defined as three cards of the same face
- * + two cards of the same face, other than the first, regardless of the card's suits.
- * The cards faces are "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" and "A".
- * The card suits are "♣", "♦", "♥" and "♠".
- * Write a program to generate and print all full houses and print their number. */
- public class _03_FullHouse {
- private static String[] faceCards = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" };
- private static char[] suitCards = { '\u2663', '\u2666', '\u2665', '\u2660' };
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int countFullHouses = generateAndPrintAllFullHouses();
- System.out.println();
- System.out.printf("The all combinations of generated full houses are: %d full houses!%n",
- countFullHouses);
- }
- private static int generateAndPrintAllFullHouses() {
- int counter = 0;
- System.out.println("The all combinations of generated full houses with Jokers are:");
- int f1, f2;
- int[] colors;
- for (f1 = 0; f1 < faceCards.length; f1++) {
- for (f2 = 0; f2 < faceCards.length; f2++) {
- if (f2 != f1) {
- colors = new int[5];
- for (colors[0] = 0; colors[0] < suitCards.length; colors[0]++) {
- for (colors[1] = colors[0] + 1; colors[1] < suitCards.length; colors[1]++) {
- for (colors[2] = colors[1] + 1; colors[2] < suitCards.length; colors[2]++) {
- for (colors[3] = 0; colors[3] < suitCards.length; colors[3]++) {
- for (colors[4] = colors[3] + 1; colors[4] < suitCards.length; colors[4]++) {
- counter++;
- printTheNextFullHouse(f1, f2, colors);
- }
- }
- }
- }
- }
- }
- }
- }
- return counter;
- }
- private static void printTheNextFullHouse(int face1, int face2, int[] colors) {
- System.out.printf("(%1$s%2$s %1$s%3$s %1$s%4$s ", faceCards[face1],
- suitCards[colors[0]], suitCards[colors[1]],
- suitCards[colors[2]]);
- System.out.printf("%1$s%2$s %1$s%3$s) ", faceCards[face2],
- suitCards[colors[3]], suitCards[colors[4]]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement