AP Computer Science --- Haas --- ArrayOfCards

Objective: Using Arrays



/**
 *  creates a Card with rank and a suit   <<< CODE COMPLETE!!! >>>
 */
public class Card   {
  private String rank;
  private String suit;
  
  public Card(String cardSuit, String cardRank)  {
      rank = cardRank;
      suit = cardSuit;
  }
  public String getRank() { return rank;}
  public String getSuit() {  return suit; }

}  


 /** 
 * <<< CODE NOT COMPLETE >>>
 * makes a deck of cards, has methods to shuffle, cut and print deck  
 */
public class Deck 
{  
   private Card[] myDeck = new Card[52]; // declare array of 52 cards
   
   /**
    * makes a deck of 52 cards
    */
    public Deck()
    { 
        makeDeck(); // calls method to make a deck of cards
    }
    
    /**
     * <<< complete the code >>> 
     * uses arrays suit and array rank to make a deck of 52 cards
     */
    public void makeDeck() {
        String[] suit = { "Clubs", "Diamonds", "Hearts", "Spades" }; 
        String[] rank = { "2", "3", "4", "5", "6", "7", "8", "9", 
                           "10" , "Jack", "Queen", "King", "Ace" };
                           
        
        /** <<< complete the code below >>>                           
         * create a deck of 52 cards by using arrays of suit and rank
         */
       
    }
                      
    
    /** 
     * <<< complete the code >>>
     * prints out the entire deck in current order
     * 
     *   Example: 2 of Clubs
     *            3 of Clubs
     *            4 of Clubs...
     */
    public void printCards() {
        
      /// COMPLETE THE CODE  
      
    }
    
   
    /**
     *  <<< complete the code >>>   
     *  cuts the deck: removes number of cards 
     *  indicated placs on bottom of deck 
     */
    public void cut(int atCard) {
        
         /// COMPLETE THE CODE 
       
    }    
        
    /** 
     * <<< complete the code >>>
     *  shuffles the deck by passing through all of  
     *  cards and swapping each card with a card
     *  at a ramdom position
     */
    public void shuffle() {
 
        /// COMPLETE THE CODE 
        
    }

} 


/**
 * Tester for Deck class <<>>
 */
public class DeckTester 
{  
   public static void main(String[] args)
   {
     Deck aDeck = new Deck();
     System.out.println("---------- new deck -----------");
     aDeck.printCards();  
     
     aDeck.cut(10);
     System.out.println("---------- after cut -----------");
     aDeck.printCards(); 

     aDeck.shuffle();
     System.out.println("---------- after shuffle -----------");
     aDeck.printCards(); 
  }
}