Source of Card.java


  1: // Fig. 7.9: Card.java
  2: // Card class represents a playing card.
  3: 
  4: public class Card 
  5: {
  6:    private String face; // face of card ("Ace", "Deuce", ...)
  7:    private String suit; // suit of card ("Hearts", "Diamonds", ...)
  8: 
  9:    // two-argument constructor initializes card's face and suit
 10:    public Card( String cardFace, String cardSuit )
 11:    {
 12:       face = cardFace; // initialize face of card
 13:       suit = cardSuit; // initialize suit of card
 14:    } // end two-argument Card constructor
 15: 
 16:    // return String representation of Card
 17:    public String toString() 
 18:    { 
 19:       return face + " of " + suit;
 20:    } // end method toString
 21: } // end class Card
 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:  *************************************************************************/