import java.util.Random;

/*******************************************************************
 Name: Trevor Spalt
 Date: March 12, 2007
 Section: 2
 Lab: PA2
/*******************************************************************
 * The deck class's purpose is to make a deck of 52 different cards.
 * It is to shuffle those cards so that they are randomly put in the
 * array and then it is to deal out the cards one by one to the dealer.
 * Finally, the deck method is to print out the deck if asked for by the
 * dealer.
 */
   public class Deck
   {  
		
		private Card deckArray[] = new Card[52];
		
		// This variable allows me to increment the card that is givin out
		// by one each time the deal method is called
		private int count;
		
		/*******************************************************************
		* The constructor fills the deckArray with the 52 different cards in
		* order using a for each loop that will look at all suits and ranks
		*
 		*******************************************************************/
		public Deck()
		{
			int counter;
			counter = 0;
			count = 0;
			
			for (Suit suit : Suit.values())
			{
            for (Rank rank : Rank.values())
				{
               deckArray[counter] = new Card(rank, suit);
					counter++;
				}
			}
		}// end constructor
		
		/*******************************************************************
		* This method will shuffle the cards using random indexes in order to
		* swap the cards within the indexes.
 		*******************************************************************/
		public void Shuffle()
		{
			// use a random num generator to get random indexes to
			// to swap for the shuffle
			Random generator = new Random();
			int cardIndex1, cardIndex2;
			Card tempHold;
			
			// This shuffles the cards a total of 55 times to make
			// sure the cards are well shuffled
			for(int counter = 0; counter < 55; counter++)
			{
				cardIndex1 = generator.nextInt(52);
				cardIndex2 = generator.nextInt(52);
				
				tempHold = deckArray[cardIndex1];
				deckArray[cardIndex1] = deckArray[cardIndex2];
				deckArray[cardIndex2] = tempHold;
			}// end for
		}// end Shuffle()*/
		
		/*******************************************************************
		* The deal method will return a single card at a time to the main
		* driver which will simulate the dealer.
		*
		* @return deckArray - return a continuous card 52 times for each card
		*                     in the array
 		*******************************************************************/
   	public Card Deal()
		{
			count++;
			
			return deckArray[count - 1];
		}// end Deal()
		
		/*******************************************************************
		* The toString method will return the entire deck.
 		*******************************************************************/
   	public String toString()
		{
			// returns the requesed card index by the dealer or driver.
			return "";
		}// end toString()
	
	}// end Deck Class