Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /**
  2. * Project 2
  3. * @author Gerald Cohen, Ph.D.
  4. */
  5. public final class Card {
  6.  
  7. private static final String[] suits = {"C", "D", "H", "S"};
  8. private static final String[] names = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
  9. private final int cardNumber;
  10. private String suit, name;
  11.  
  12. public Card(int name, int suit, int cardNumber) {
  13. this.cardNumber = cardNumber;
  14. this.suit = suits[suit - 1];
  15. this.name = names[name - 1];
  16. }
  17.  
  18. /**
  19. * Return the numerical value of the card
  20. * @return face value 1 to 13
  21. */
  22. public int getFaceValue() {
  23. return cardNumber;
  24. // TODO - return the face value of a card
  25. }
  26.  
  27. public String toString() {
  28. // TODO - complete so that the string representation of a card is correct
  29. return name + " of " + suit;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement