Advertisement
Guest User

java07

a guest
Aug 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. public class Cards {
  4.  
  5.     public static void main(String[] args) throws IOException {
  6.         /**Inputs are 4C for Four of Clubs. Jack is 11, Queen is 12, King is 13, Ace is 14*/
  7.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  8.         StringTokenizer st = new StringTokenizer(br.readLine());
  9.         Set<Integer> numberSet = new HashSet<Integer>();
  10.         Set<String> suitSet = new HashSet<String>();
  11.         boolean flush = false;
  12.         int[] count = {0,0,0,0,0,0,0,0,0,0,0,0,0};
  13.         for(int i = 0; i<5; i++) {
  14.             char[] token = st.nextToken().toCharArray();
  15.             count[Character.getNumericValue(token[0])-1] += 1;
  16.             numberSet.add(Character.getNumericValue(token[0]));
  17.             suitSet.add(Character.toString(token[1]));
  18.             }
  19.         Arrays.sort(count);
  20.         if (suitSet.size() == 1) {
  21.             flush = true;
  22.             System.out.print("flush");
  23.         }
  24.         if (numberSet.size() == 2) {
  25.             if (count[12]==4)
  26.                 System.out.println("four-of-a-kind");
  27.             else
  28.                 System.out.println("full house");
  29.         }
  30.         if (numberSet.size() == 3) {
  31.             if (count[12]==3)
  32.                 System.out.println("three-of-a-kind");
  33.             else
  34.                 System.out.println("two pairs");
  35.         }
  36.        
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement