Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. package model.card;
  2.  
  3. /**
  4. * This interface is used to represent a single card and should be implemented
  5. * by the concrete class {@link model.card.CardImpl}
  6. *
  7. * @author Ross Nye
  8. *
  9. * @see model.card.CardImpl
  10. * @see model.card.Suit
  11. * @see model.card.Rank
  12. *
  13. */
  14. public interface Card extends Comparable<Card>
  15. {
  16. /**
  17. * A simple getter to return the suit of card.
  18. *
  19. * @return the card's suit
  20. *
  21. * @see model.card.Suit
  22. */
  23. public Suit getSuit();
  24.  
  25. /**
  26. * A simple getter to return the rank of card.
  27. *
  28. * @return the card's rank.
  29. *
  30. * @see model.card.Rank
  31. */
  32. public Rank getRank();
  33.  
  34. /**
  35. * Returns the value of the card's rank.
  36. *
  37. * <p>
  38. * Number cards return their face value. Ace returns 1. Court Cards (J,Q,K)
  39. * return 10.
  40. *
  41. * @return the value of the card's rank.
  42. *
  43. * @see model.card.Rank
  44. */
  45. public int getValue();
  46.  
  47. /**
  48. * Overrides the method {@link java.lang.Object#equals(Object)} to provide a
  49. * method to testing equality for {@link model.card.Card} objects.
  50. *
  51. * <p>
  52. * The same rules of reflexivity, symmetry, transitivity, and consistency
  53. * apply. However, the two object should be tested and treated as
  54. * {@link model.card.Card} objects and the two fields compared. If both the
  55. * {@link model.card.Suit} and the {@link model.card.Rank} are equal, the
  56. * {@link model.card.Card} objects are equal.
  57. *
  58. *
  59. * @param obj
  60. * the reference object with which to compare.
  61. *
  62. * @return {@code true} if this {@link model.card.Card} object is the same
  63. * as the obj argument; {@code false} otherwise
  64. *
  65. * @see java.lang.Object#equals(Object)
  66. * @see model.card.Suit
  67. * @see model.card.Rank
  68. */
  69. @Override
  70. public boolean equals(Object obj);
  71.  
  72. /**
  73. * Overrides the method {@link java.lang.Object#hashCode()}.
  74. *
  75. * <p>
  76. * See {@link java.lang.Object#hashCode()} for relevant information for
  77. * implementing this method.
  78. *
  79. * @return a hash code value for this object.
  80. */
  81. @Override
  82. public int hashCode();
  83.  
  84. /**
  85. * Override {@link java.lang.Comparable#compareTo(Object)} Compares this
  86. * Card with the supplied Card for order. Returns a negative integer, zero,
  87. * or a positive integer if this Card is less than, equal to, or greater
  88. * than the supplied Card.
  89. *
  90. * <p>
  91. * If the two cards are of the same suit the card ranks used to make the
  92. * comparison, using the natural order or rank (Ace, 2, ... 10, Jack, Queen,
  93. * King). However if the cards are of different suit, then the suit order is
  94. * used which determined by ascending alphabetical order: clubs (lowest),
  95. * followed by diamonds, hearts, and spades (highest)
  96. *
  97. * @return a negative integer, zero, or a positive integer representing the
  98. * order of the two cards as above
  99. *
  100. */
  101. @Override
  102. public int compareTo(Card card);
  103.  
  104. /**
  105. * Override {@link java.lang.Object#toString()}.
  106. *
  107. * Generates a string representing the card as seen in the output trace. The
  108. * following are examples of such strings.
  109. * <ul>
  110. * <li>2 of Clubs
  111. * <li>7 of Diamonds
  112. * <li>Queen of Hearts
  113. * <li>Ace of Spades
  114. * </ul>
  115. *
  116. * @return a string representing the card as seen in the output trace
  117. */
  118. @Override
  119. public String toString();
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement