Source of DeckOfCardsTest.java


  1: // Fig. 7.11: DeckOfCardsTest.java
  2: // Card shuffling and dealing application.
  3: 
  4: public class DeckOfCardsTest
  5: {
  6:    // execute application
  7:    public static void main( String args[] )
  8:    {
  9:       DeckOfCards myDeckOfCards = new DeckOfCards();
 10:       myDeckOfCards.shuffle(); // place Cards in random order
 11:       
 12:       // print all 52 Cards in the order in which they are dealt
 13:       for ( int i = 0; i < 13; i++ )
 14:       {
 15:          // deal and print 4 Cards
 16:          System.out.printf( "%-20s%-20s%-20s%-20s\n", 
 17:             myDeckOfCards.dealCard(), myDeckOfCards.dealCard(),  
 18:             myDeckOfCards.dealCard(), myDeckOfCards.dealCard() );
 19:       } // end for
 20:    } // end main
 21: } // end class DeckOfCardsTest
 22: 
 23: 
 24: /**************************************************************************
 25:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 26:  * Pearson Education, Inc. All Rights Reserved.                           *
 27:  *                                                                        *
 28:  * DISCLAIMER: The authors and publisher of this book have used their     *
 29:  * best efforts in preparing the book. These efforts include the          *
 30:  * development, research, and testing of the theories and programs        *
 31:  * to determine their effectiveness. The authors and publisher make       *
 32:  * no warranty of any kind, expressed or implied, with regard to these    *
 33:  * programs or to the documentation contained in these books. The authors *
 34:  * and publisher shall not be liable in any event for incidental or       *
 35:  * consequential damages in connection with, or arising out of, the       *
 36:  * furnishing, performance, or use of these programs.                     *
 37:  *************************************************************************/