Advertisement
Guest User

Untitled

a guest
May 14th, 2014
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3.  
  4. public class FullHouse {
  5.  
  6.     public static void main(String[] args) {
  7.         String[] cards = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K","A"};
  8.         String[] faces = {"♣", "♦", "♥", "♠" };
  9.         int fullHouseCount = 0;
  10.         ArrayList<String> allCards = new ArrayList<String>();
  11.         for (String card : cards) {
  12.             for(String face : faces){
  13.                 String tempcard = card+face;
  14.                 allCards.add(tempcard);
  15.             }
  16.         }
  17.         for (String card1 : allCards) {
  18.             for (String card2 : allCards) {
  19.                 for (String card3 : allCards) {
  20.                     for (String card4 : allCards) {
  21.                         for (String card5 : allCards) {
  22.                             if(card1.charAt(0)==card2.charAt(0)&&card2.charAt(0)==card3.charAt(0)){
  23.                                 if(card4.charAt(0)!=card1.charAt(0)&&card4.charAt(0)==card5.charAt(0)){
  24.                                     System.out.printf("(%s%s%s%s%s)%n",card1,card2,card3,card4,card5);
  25.                                     fullHouseCount++;
  26.                                 }
  27.                             }
  28.                         }
  29.                     }
  30.                 }
  31.             }
  32.         }
  33.         System.out.println(fullHouseCount);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement