Evaluating Poker Hands

Poker Hands
Poker hands are always a pain to evaluate during a contest. This code evaluates hands using math for the standard five card draw hand system, with the following hand rankings:

Straight Flush

4-of-a-kind

Full House

Flush

Straight

3-of-a-kind

2-pair

1-pair

High Card

The function returns a single long (doesn't overflow ever, of course :D). The higher the number, the better the hand.

If evaluating a Texas Hold 'Em hand, then try all 7 C 5 possible hands and just use the best one.

Java
public static long valueHand(card[] x)   { long answer = 0 ; Arrays.sort(x) ; int straightMax = 0 ; boolean str,flush ;flush = false ;str = true ; // flush if ((x[0].suit == x[1].suit) && (x[1].suit == x[2].suit) && (x[2].suit == x[3].suit) &&               (x[3].suit == x[4].suit)) {           flush = true ; }       for (int i = 1 ; i < 5 ; i ++) {           if ((i == 4) && (x[4].value == 13) && (x[3].value == 4)) continue ; if (x[i].value == (x[i-1].value + 1)) continue ; else {               str = false ; break ; }       }        if (str) {           straightMax = x[4].value ; if (x[4].value == 13 && x[3].value == 4) straightMax = 4 ; }       if (flush && str) {           answer += (long)Math.pow(14,12) * straightMax ; System.out.println("Straight Flush"); }       else if (flush) {           answer += (long)Math.pow(14, 9) * x[4].value ;//multiplication not rly necessary due to kickerz System.out.println("Flush"); }       else if (str) {           answer += (long)Math.pow(14,8) * straightMax ; System.out.println("Straight"); }       int[] tmp = new int[14] ; for (int i = 0 ; i < 5 ; i ++) {           tmp[x[i].value] ++ ; }       int majorSet,minorSet, majorNum, minorNum ;majorSet = minorSet = majorNum = minorNum = 0 ; for (int i = 13 ; i >= 0 ; i --) {           if (tmp[i] > 1 && majorNum == 0) {               majorNum = tmp[i] ; majorSet = i ; }           else if (tmp[i] > 1 && majorNum > 0) {               if (tmp[i] > majorNum) {                   minorSet = majorSet ; minorNum = majorNum ; majorNum = tmp[i] ; majorSet = i ; }               else {                   minorNum = tmp[i] ; minorSet = i ; }           }        }        if (majorNum == 4) {           // four of a kind answer += (long)Math.pow(14,11) * majorSet ; answer += (long)Math.pow(14,5) * minorSet ; System.out.println("4 of a kind"); }       if (majorNum == 3 && minorNum == 2) {           // full house answer += (long)Math.pow(14,10) * majorSet ; System.out.println("Full House"); }       if (majorNum == 3 && minorNum == 0) {           // 3 of a kind System.out.println("3 of a kind"); answer += (long)Math.pow(14,7) * majorSet ; }       if (majorNum == 2 && minorNum == 2) {           // 2 pair answer += (long)Math.pow(14,6) * majorSet ; answer += (long)Math.pow(14,5) * minorSet ; System.out.println("2 pair"); }       if (majorNum == 2 && minorNum == 0) {           // 1 pair answer += (long)Math.pow(14,5) * majorSet ; System.out.println("1 pair"); }       // value rest of hand with the math! for (int i = 4 ; i >= 0 ; i --) {           answer += (long)Math.pow(14,i)*x[i].value ; }       return answer ; }   Class card implements Comparable&lt;card&gt; {   int value ; // A = 13, deuce = 1. Ace also is 0 when checking for a straight (ace, deuce...five is a straight). int suit ; // clubs, spades, hearts, diamonds -> {0,1,2,3} public int compareTo(card newX) {       return this.value - newX.value ; }   public card {       // U like zergz? value = suit = -1 ; } } USE: card[] X = new card[5] ; X[0] = new card ; X[1] = new card ; X[2] = new card ; X[3] = new card ; X[4] = new card ; X[0].value = 13 ; X[0].suit = 3 ; X[1].value = 12 ; X[1].suit = 3 ; X[2].value = 11 ; X[2].suit = 3 ; X[3].value = 10 ; X[3].suit = 3 ; X[4].value = 9 ; X[4].suit = 3 ; Arrays.sort(X); for (int i = 0 ; i <= 4 ; i ++) System.out.println(X[i].value + " " + X[i].suit); System.out.println(valueHand(X)) ; // Straight Flush, Ace High