
import java.util.Random;

/*
 * This class stores a 5 Card poker
 * hand as an array.  It illustrates
 * various array operations, control
 * statements, and features of Java.
 */
public class PokerHand {

    static protected final int NUM_CARDS = 5;

    protected Card cards[];

    /*
     * Create a new random hand.
     */
    public PokerHand() {
        // allocate array and create random number generator
        cards = new Card[NUM_CARDS];
        Random gen = new Random();

        for (int i = 0; i < cards.length; i++) {

            // pick new rank and suit values randomly
            cards[i] = new Card(gen.nextInt(13) + 2,
                                gen.nextInt(4));
        }
    }

    /*
     * Return the string representation of the Poker Hand
     */
    public String toString() {
        String result = "";
        for (int i = 0; i < cards.length; i++) {
            result = result + cards[i] + "\n";
        }
        return result;
    }

    /*
     * Return true if all cards have the same suit.
     */
    protected boolean isFlush() {
        int suit = cards[0].getSuit();
        for (int i = 1; i < cards.length; i++) {
            if (suit != cards[i].getSuit()) {
                return false;
            }
        }
        return true;
    }
                                           
    public static void main(String s[]) {
        PokerHand hand = new PokerHand();
        System.out.println();
        System.out.println(hand);
        System.out.println("=====> " + hand.scoreHand());
        System.out.println();
    }


}
