0
import java.util.ArrayList;
import java.util.Collections;
/**
 * Write a description of class Deck here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Dealer
{
    private int numberOfDecks = 1;
    private int numberOfCards = Suits.numberOfSuits * Ranks.numberOfRanks * numberOfDecks;
    private ArrayList<Card> allCards = new ArrayList<Card>();
    private int indexCard; 


    public Dealer(){
        makeDeck();
        indexCard = 0;

    }
    /** 
     * Method to deal a card
     */
    public void dealCard(){
        Card dealt = allCards.get(indexCard);
        indexCard = indexCard + 3; 
        System.out.println(dealt);


    }

    /**
     * makes a new deck
     */
    private void makeDeck(){
        Card temp;
        for(int i = 0; i < numberOfDecks; i++){
            for(Suits s: Suits.values() ){
                for(Ranks r: Ranks.values()){
                    temp = new Card (r, s);
                    allCards.add(temp);
                }
            }

How can I deal 3 cards so I can later evaluate them based on their rank? This is what I have so far, but I do not believe me dealHand() method will do me much good in terms of evaluating ranks.

  • At least show us your attempt at coding `dealHand()` – Vivin Paliath Apr 10 '14 at 18:30
  • public void dealHand(){ dealCard(); dealSecondCard(); dealThirdCard(); } I also have methods that will deal a secondCard() and a thridCard() – user3372158 Apr 10 '14 at 18:53
  • Aren't you always going to deal exactly the same hand? Once you have your deck, you could use allCards.shuffle() to shuffle it. You could store each hand in some type of collection, and then have a method that evaluates that collection. – Darius X. Apr 10 '14 at 19:25
  • I have a shuffle method already which shuffles the deck each time one of my dealCard() dealSecondCard() dealThirdCard() or dealHand() is called. How could I store the results into a collection? My ultimate goal is to store the results of the dealHand() method 500 times then evaluate each one and post the frequencies – user3372158 Apr 10 '14 at 19:34

0 Answers0