   import java.util.*;

/**
 * A driver for experimenting with the PlayingCard
 * class and the Comparable interface
 */
    public class Driver
   {
    /**
     * The entry point
     *
     * @param args   The command-line arguments
     */
       public static void main(String[] args)
      {
         int                    i;
         PlayingCard[]          cards;
         Deck 						  myDeck;  // declare a Deck object
         Hand						  myHand;  // declare a Hand object
         int                    temp;    // was removal successful or not
         Card						  tempCard; // temporarily holds a Card
      
      
      // Construct the cards
         cards = new PlayingCard[5];
         cards[0] = new PlayingCard(Card.CLUBS,    Card.ACE);
         cards[1] = new PlayingCard(Card.CLUBS,    4);
         cards[2] = new PlayingCard(Card.DIAMONDS, Card.QUEEN);
         cards[3] = new PlayingCard(Card.SPADES,   Card.ACE);
         cards[4] = new PlayingCard(Card.HEARTS,   4);
      
      
      
      	// Print the cards in the original order
         for (i=0; i < cards.length; i++)
         {
            System.out.println(cards[i]);
         }
         System.out.println();  // took out the \n\n
      
      	// Sort the cards
         Arrays.sort(cards);
      
      
      	// Print the cards in the sorted order
         for ( i=0; i < cards.length; i++)
         {
            System.out.println(cards[i]);
         }
         System.out.println(); // for spacing
         System.out.println (" Part II output follows "); /// header
      
      // Add code here for Part II
      
      // first make a deck of cards
         myDeck = new Deck(); // instantiating a Deck object
        
              // create a hand of 5 cards
         myHand = new Hand(5);  // instantiating a 5 card Hand object
      
      
      // fill the hand with 5 random cards from the deck
         myDeck.shuffle();  // so the cards will be random not ordered
         for (i = 0; i < 5; i++)
         {
            if (myDeck.hasMoreCards())  // checking that there is a Card
            { 
               tempCard = myDeck.nextCard();
               myHand.addCard(tempCard);
            }
         }
      //		System.out.println (myHand);// erroneous - prints a hash code 
         System.out.println (" Original hand ");  // header
         myHand.displayHand();  // displays hand two ways	 
         System.out.println ();
      
      // get rid of the third card (since we don't know in advance)
         temp = myHand.removeCard(3);// should check that card X exists
      
      // display new hand
      // System.out.println (myHand);
         System.out.println (" Modified hand ");
         myHand.displayHand();
         System.out.println();
      
      // deal a new card to replace it
         if (myDeck.hasMoreCards())// want to avoid an exception
         { 
            tempCard = myDeck.nextCard();
            myHand.addCard(tempCard);
         }
      
      // display new hand
      // System.out.println (myHand);
         System.out.println (" Re-Modified hand ");
         myHand.displayHand();
         System.out.println();
      
      }
   
   }
