You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
804 B

6 years ago
  1. // The Card class that represents cards
  2. // Do not make any changes to this file!
  3. // Xiwei Wang
  4. import java.io.*;
  5. public class Card implements Serializable
  6. {
  7. // instance variables
  8. private int m_suit;
  9. private int m_rank;
  10. // constructor
  11. public Card(int suit, int rank)
  12. {
  13. m_suit = suit;
  14. m_rank = rank;
  15. }
  16. // getters
  17. public int getSuit()
  18. {
  19. return m_suit;
  20. }
  21. public int getRank()
  22. {
  23. return m_rank;
  24. }
  25. // return a string representation of the card
  26. public String toString()
  27. {
  28. String[] suitChars = {"C", "D", "H", "S"};
  29. String[] rankChars = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
  30. return suitChars[m_suit] + rankChars[m_rank];
  31. }
  32. }